Converting GridView Code to RadGrid Code

3 posts, 0 answers
  1. Stardome20
    Stardome20 avatar
    7 posts
    Member since:
    Nov 2012

    Posted 28 Nov 2012 Link to this post

    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. Stardome20
    Stardome20 avatar
    7 posts
    Member since:
    Nov 2012

    Posted 28 Nov 2012 Link to this post

    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("");
        }
    }
  3. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 29 Nov 2012 Link to this post

    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.
Back to Top