Monday, March 22, 2010

Looping thru Infragistics WebDataGrid on the Server



Took me a while to find this. With some help from ig, thank you Chandradeep!



protected void Button1_Click(object sender, EventArgs e)
{
// loop thru selected cells and get their values
foreach (GridRecordItem itm in WebDataGrid1.Behaviors.Selection.SelectedCells)
{
object ttt = itm.Text ;
}

// example of looping thru selected rows and getting values of columns
foreach (GridRecord row in WebDataGrid1.Behaviors.Selection.SelectedRows)
{
object ttt = row;
GridRecordItem itm = row.Items[0];
string sffssdf = itm.Text;
itm = row.Items[1];
sffssdf = itm.Text;
itm = row.Items[2];
sffssdf = itm.Text;
}

// example of looping thru all rows and getting values of columns
foreach (GridRecord row in WebDataGrid1.Rows)
// foreach (GridRecordItem row in WebDataGrid1.Behaviors.Selection.SelectedCells)
{
object ttt = row;
GridRecordItem itm = row.Items[0];

string sffssdf = itm.Text;
itm = row.Items[1];
sffssdf = itm.Text;
itm = row.Items[2];
sffssdf = itm.Text;
}

// example of looping thru all rows and getting values of a checkbox in a column template field!!!!!
foreach (GridRecord row in WebDataGrid1.Rows)
// foreach (GridRecordItem row in WebDataGrid1.Behaviors.Selection.SelectedCells)
{
CheckBox theCB = (CheckBox)row.Items[0].FindControl("cb1");
bool ischecked = theCB.Checked;
object ttt = row;
GridRecordItem itm = row.Items[0];


string sffssdf = itm.Text;
itm = row.Items[1];
sffssdf = itm.Text;
itm = row.Items[2];
sffssdf = itm.Text;
}


}

No comments:

Post a Comment