J
Joel Lyons
The help pages make it look like the DataGridItem.DataItem property would
return a row from the bound table. Like so:
//(during setup)
myGrid.DataSource = myDataset.MyTable;
myGrid.DataBind();
//(in OnSelectedIndexChanged)
MyTableRow row = myGrid.SelectedItem.DataItem as MyTableRow;
myLabel.Text = "You selected: " + row.Name;
But this doesn't work! The DataItem property always returns null (so the
cast does also). Am I using this correctly? Is there a different way to
retrieve the DataSet row that was bound to the Grid row?
-Joel
return a row from the bound table. Like so:
//(during setup)
myGrid.DataSource = myDataset.MyTable;
myGrid.DataBind();
//(in OnSelectedIndexChanged)
MyTableRow row = myGrid.SelectedItem.DataItem as MyTableRow;
myLabel.Text = "You selected: " + row.Name;
But this doesn't work! The DataItem property always returns null (so the
cast does also). Am I using this correctly? Is there a different way to
retrieve the DataSet row that was bound to the Grid row?
-Joel