Get selected row values when linkbutton clicked in a GridTemplateColumn

6 posts, 0 answers
  1. suresh kumar
    suresh kumar avatar
    7 posts
    Member since:
    May 2010

    Posted 20 May 2010 Link to this post

    Hi,
    I am facing with an issue.
    I had a linkbutton in GridTemplateColumn, when i click this linkbutton i need to get all the values from that row.
    thanks in advance.

    Regards,
    Suresh Kumar Udatha.
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 20 May 2010 Link to this post

    Hello Suresh,

    You can get reference to the GridDataItem using NamingContainer property of LinkButton and can access the value using ColumnUniqueName. Check out the following code snippet.

    C#:
     protected void LinkButton1_Click(object sender, EventArgs e) 
        { 
            LinkButton btn = (LinkButton)sender; 
            GridDataItem item = (GridDataItem)btn.NamingContainer; 
            string name = item["ColumnUniqueName1"].Text;
        } 

    Regards,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. suresh kumar
    suresh kumar avatar
    7 posts
    Member since:
    May 2010

    Posted 20 May 2010 Link to this post

    Hi Shanu,
    Thanks for your valuable code. Your code really helped a lot.
    Thankyou for your support once again.
    Regards,
    Suresh Kumar udatha.
  5. Spiros
    Spiros avatar
    15 posts
    Member since:
    May 2010

    Posted 26 May 2014 Link to this post

    Hi Shanu , I am facing a similar situation . I have places
                                                <telerik:GridTemplateColumn UniqueName="isoptianal" DataField="isoptianal">
                                                    <ItemTemplate>
                                                        <asp:CheckBox ID="CheckBox1" AutoPostBack="true" OnCheckedChanged="CheckDisount_CheckedChanged" runat="server" />
                                                    </ItemTemplate>
                                                </telerik:GridTemplateColumn>

    and When i Click on the checkbox i need to get the  <MasterTableView AutoGenerateColumns="False" ClientDataKeyNames="Id" DataKeyNames="Id"> .
    Do you have any idea ?
  6. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 26 May 2014 in reply to Spiros Link to this post

    Hi Spiros,

    I guess you want to get the DataKeyNames value on the CheckChanged event. Please try the following code snippet.

    C#:
    protected void CheckDisount_CheckedChanged(object sender, EventArgs e)
    {
     CheckBox chkDiscount = (CheckBox)sender;
     GridDataItem dataItem = (GridDataItem)chkDiscount.NamingContainer;
     //Get the DataKeyName
     string Id = dataItem.GetDataKeyValue("Id").ToString();
    }

    Thanks,
    Shinu
  7. Spiros
    Spiros avatar
    15 posts
    Member since:
    May 2010

    Posted 26 May 2014 in reply to Shinu Link to this post

    Yes Thanks a lot , I find this solution and works fine.
    I am very happy that we choose telerik insted of some other. company.
    Cheers
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017