This is a migrated thread and some comments may be shown as answers.

Grid Add

1 Answer 28 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Thomas
Top achievements
Rank 1
Thomas asked on 15 Jan 2013, 08:15 PM
I have a datatable bound to a radgrid. On Add click of a button. I want to open the radgrid row that I just appended to the table.

Thanks
Thomas

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 16 Jan 2013, 07:18 AM
Hi,

Try the following code to achieve your scenario.
C#:
protected void RadGrid1_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
   {
       if (e.CommandName == "CommandName")
       {
           string select = "SELECT TOP 1 EmployeeID FROM Employees ORDER BY EmployeeID DESC";
           SqlCommand.CommandText = select;
         SqlCommand.Connection = conn;
           SqlDataAdapter da = new SqlDataAdapter(SqlCommand);
           dt = new DataTable();
           da.Fill(dt);
          int value = Convert.ToInt16(dt.Rows[0]["EmployeeID"].ToString());
           foreach (GridDataItem item in RadGrid1.Items)
           {
               int ID = Convert.ToInt16(item["EmployeeID"].Text);
               if (ID == value)
               {
                   item.Selected = true;
               }
           }
 }
}

Thanks,
Princy
Tags
Grid
Asked by
Thomas
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Share this question
or