Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
935
Cant get Selected Row when WebDatgrid is Binded by a Datatabe
posted

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??

 

 

 

Parents
No Data
Reply Children
No Data