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

Grid for update

2 Answers 44 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Susi
Top achievements
Rank 1
Susi asked on 18 Jun 2012, 11:25 AM
Dear All,
    I have developing product in 4 tier architecture by asp.net using c sharp and i have done RadGrid but how navigate from grid page to update page with ID.how to pass id from grid page to update page without using NavigateURL

my code is:
<telerik:RadGrid ID="radgrdUserList" runat="server" AllowPaging="true" AllowSorting="true"
                AutoGenerateColumns="false" >
                <MasterTableView ClientDataKeyNames="ID" DataKeyNames="ID">
                    <Columns>
                        <telerik:GridTemplateColumn UniqueName="UserName" HeaderText="User Name">
                            <ItemTemplate>
                                <asp:HyperLink ID="lnkUserName" runat="server" Text='<%#Eval("UserName") %>' NavigateUrl='<%#"~/UserDetails.aspx?ID=" +
                                                                Eval("ID") %>'></asp:HyperLink></ItemTemplate>
                        </telerik:GridTemplateColumn>
                        <telerik:GridBoundColumn HeaderText="First Name" UniqueName="FirstName" DataField="FirstName">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn HeaderText="Last Name" UniqueName="LastName" DataField="LastName">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn HeaderText="Date of Join" UniqueName="DOB" DataField="DOB">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn HeaderText="Created By" UniqueName="CreatedBy" DataField="CreatedBy">
                        </telerik:GridBoundColumn>
                          </Columns>
                </MasterTableView></telerik:RadGrid>

When i click UserName then pass Id from gridview page to update page in code behind code using query string or session, and how to receive ID in update page for update particular row details.

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 18 Jun 2012, 12:21 PM
Hello Susi,

Since it is not possible to handle any server events for a hyperlink, one suggestion is you can use a LinkButton and access the datakeyvalue as shown below.
aspx:
<telerik:GridTemplateColumn>
 <ItemTemplate>
      <asp:LinkButton ID="LinkButton1" runat="server" Text="pp" onclick="LinkButton1_Click"></asp:LinkButton>
 </ItemTemplate>
</telerik:GridTemplateColumn>

C#:
protected void LinkButton1_Click(object sender, EventArgs e)
{
   LinkButton link = (LinkButton)sender;
   GridDataItem item = (GridDataItem)link.NamingContainer;
   string value = item.GetDataKeyValue("ID").ToString();
}

Thanks,
Princy.
0
Susi
Top achievements
Rank 1
answered on 18 Jun 2012, 01:13 PM
Thank you very much princy..
Tags
Grid
Asked by
Susi
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Susi
Top achievements
Rank 1
Share this question
or