I used this code to Get the value of selected row in Datagrid
if (WebDataGrid1.Behaviors.Selection.SelectedRows.Count > 0)
{
foreach (GridRecord selectedRow in WebDataGrid1.Behaviors.Selection.SelectedRows)
// errors out here with selectedRow returning null
tmp = selectedRow.Items.GetValue(0).ToString();
var dt = (DataTable) Session["data"];
DataRow row = dt.Rows.Find(tmp);
row.Delete();
}
WebDataGrid1.DataSource = (DataTable)Session["data"];
WebDataGrid1.DataBind();
else
lblError.Text = @"Please Select Row";
lblError.ForeColor = Color.Red;
return;
It works if i used sqldatasource to bind data in WebDatagrid.
But When i used DataTable to Bind Data in WebDatagrid it always return me null selected value.
Why this happens? Any Idea??
Got the answer i just need to Add WebDatagrid.Datasource and Databind on the upper part .