0

I have a radgrid1 and inside radgrid Item template i have two asp.net imagebutton namely imagebutton1 and imagebutton2 ....

i want when i click on Selected radgrid Item whose id is id then after clicking on Image Button1 i redirect to ~/book.aspx?id=1

and if i click on imagebutton2 then i redirect to ~/details.aspx?id=1

Note : the id of the item will be changed dynamically according to the selected radgrid row .

I have already done it using simple Gridview but m unable to perform this action using radgrid.

Help me please guys...!

Sumit Dobriyal
  • 79
  • 1
  • 1
  • 6

1 Answers1

0

Please check below code snippet.

.aspx

<MasterTableView DataKeyNames="Id"
            >
            <Columns>

                <telerik:GridTemplateColumn>
                    <ItemTemplate>
                        <asp:ImageButton  ID="ImageButton1" runat="server"  CommandName="BookPage"/>
                        <asp:ImageButton  ID="ImageButton2" runat="server"  CommandName="DetailPage"/>
                    </ItemTemplate>
                </telerik:GridTemplateColumn>


            </Columns>
        </MasterTableView>

.asp.cs

  protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
{
    GridDataItem item = e.Item as GridDataItem;

    string strId = item.GetDataKeyValue("Id").ToString();

    if (e.CommandName == "BookPage")
    {
        Response.Redirect("~/book.aspx?id=" + strId);
    }
    else if (e.CommandName == "DetailPage")
    {
        Response.Redirect("~/details.aspx?id=" + strId);
    }

}

Jayesh Goyani
  • 11,008
  • 11
  • 30
  • 50