S
Sudip_inn
Guest
see my code first
string strBrokerGridXML = ConfigurationManager.AppSettings["OutputPath"].ToString().Trim() + cmbTicker.Text.ToString() + "\\" + "Broker_History.xml";
string selectedhistory = "", brokercode = "";
if (File.Exists(strBrokerGridXML))
{
DataSet ds = new DataSet();
ds.ReadXml(strBrokerGridXML);
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
brokercode = ds.Tables[0].Rows["BrokerCode"].ToString();
selectedhistory = ds.Tables[0].Rows["IsHistorySelected"].ToString();
//((DataGridViewCheckBoxCell)dgvBrokers.Rows.Cells["colSelect"]).Value = (selectedBroker.ToUpper()=="TRUE" ? true : false);
var dgvrows = dgvBrokers.Rows.OfType<DataGridViewRow>()
.Where(r => r.Cells["colBrokers"].Value.ToString().ToUpper() == brokercode.ToUpper())
.ToList();
foreach (DataGridViewRow row in dgvrows)
{
((DataGridViewCheckBoxCell)row.Cells["colHist"]).Value = (selectedhistory.ToUpper() == "TRUE" ? true : false);
}
}
}
i am iterate in rows of datatable and query grid by LINQ and setting true/false value in grid. can i avoid the above iteration and query datagridview & set cell value in one go ?
looking for code example if possible.
Continue reading...
string strBrokerGridXML = ConfigurationManager.AppSettings["OutputPath"].ToString().Trim() + cmbTicker.Text.ToString() + "\\" + "Broker_History.xml";
string selectedhistory = "", brokercode = "";
if (File.Exists(strBrokerGridXML))
{
DataSet ds = new DataSet();
ds.ReadXml(strBrokerGridXML);
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
brokercode = ds.Tables[0].Rows["BrokerCode"].ToString();
selectedhistory = ds.Tables[0].Rows["IsHistorySelected"].ToString();
//((DataGridViewCheckBoxCell)dgvBrokers.Rows.Cells["colSelect"]).Value = (selectedBroker.ToUpper()=="TRUE" ? true : false);
var dgvrows = dgvBrokers.Rows.OfType<DataGridViewRow>()
.Where(r => r.Cells["colBrokers"].Value.ToString().ToUpper() == brokercode.ToUpper())
.ToList();
foreach (DataGridViewRow row in dgvrows)
{
((DataGridViewCheckBoxCell)row.Cells["colHist"]).Value = (selectedhistory.ToUpper() == "TRUE" ? true : false);
}
}
}
i am iterate in rows of datatable and query grid by LINQ and setting true/false value in grid. can i avoid the above iteration and query datagridview & set cell value in one go ?
looking for code example if possible.
Continue reading...