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

Converting GridView Code to RadGrid Code

2 Answers 231 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Stardome20
Top achievements
Rank 1
Stardome20 asked on 28 Nov 2012, 02:01 PM
Hi This is the code for my Grid view As you know there is no RowCommand on RadGrid that why I need some help on how to convert all this code to RadGrid Code

  1.         protected void gv_Movie_RowCommand(object sender, GridViewCommandEventArgs e)
  2.         {
  3.             //get the row number of the selected row
  4.     // The error is at line 5
  5.             int rowNo = int.Parse(e.CommandArgument.ToString());
  6.             //get the selected row
  7.             GridViewRow row = gv_movie.Rows[rowNo];
  8.             //Get movie ID, which is on the 1st column of the gridview
  9.             string movieID = row.Cells[0].Text;
  10.             if (e.CommandName == "Select")
  11.             {
  12.                 Response.Redirect("");
  13.             }
  14.             else if (e.CommandName == "Update")
  15.             {
  16.                 Response.Redirect("");
  17.             }
  18.         }

2 Answers, 1 is accepted

Sort by
0
Stardome20
Top achievements
Rank 1
answered on 28 Nov 2012, 03:25 PM
I try this but it can't work too
protected
void RadGrid1_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
{
    //the error is over here which is Input string was not in a correct format.
 
    int rowNo = int.Parse(e.CommandArgument.ToString());
 
    GridDataItem row = RadGrid1.Items[rowNo];
 
    string movieID = row.Cells[0].Text;
    if (e.CommandName == "Select")
    {
        Response.Redirect("");
    }
    else if (e.CommandName == "Delete")
    {
        Response.Redirect("");
    }
}
0
Shinu
Top achievements
Rank 2
answered on 30 Nov 2012, 05:18 AM
Hi,

Please try the following code snippet.

C#:
protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
{
    int rowNo = e.Item.ItemIndex; //to get the row index
    GridDataItem row = rdGrdMenu.Items[rowNo];
    string movieID = row.Cells[0].Text;
    if (e.CommandName == "Select")
    {
        Response.Redirect("");
    }
    else if (e.CommandName == "Delete")
    {
        Response.Redirect("");
    }
}

Thanks,
Shinu.
Tags
General Discussions
Asked by
Stardome20
Top achievements
Rank 1
Answers by
Stardome20
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Share this question
or