get value in GridTemplateColumn control from another GridTemplateColumn control click

4 posts, 1 answers
  1. Yang
    Yang avatar
    6 posts
    Member since:
    Oct 2012

    Posted 13 Jul 2015 Link to this post

    get value in GridTemplateColumn control from another GridTemplateColumn control clickget value in GridTemplateColumn control from another GridTemplateColumn control clickget value in GridTemplateColumn control from another GridTemplateColumn control click
  2. Yang
    Yang avatar
    6 posts
    Member since:
    Oct 2012

    Posted 13 Jul 2015 in reply to Yang Link to this post

    sorry, i mistakenly submit the post,

    my question is i have a radgrid with 2  GridTemplateColumn, one is a textbox inside and the other has a linkbutton.

     

    when i click the link button, i want to get the text in that textbox, is this possible?

    my code is like below:

     

     <telerik:GridTemplateColumn UniqueName="TemplateColumn"  
                                FilterControlAltText="Filter TemplateColumn column">
                                <ItemTemplate>
                                    <asp:TextBox ID="txtRejectReason" runat="server"></asp:TextBox>
                                </ItemTemplate>
                            </telerik:GridTemplateColumn>



                            <telerik:GridTemplateColumn UniqueName="TemplateColumn" DataField="Name"
                                FilterControlAltText="Filter TemplateColumn column">
                                <ItemTemplate>
                                    <asp:LinkButton ID="ImageButton2" runat="server" AlternateText="" OnCommand="Reject_Click" CommandArgument='<%# Eval("ID") %>'
                                        Text="Reject" ForeColor="#993333" />
                                </ItemTemplate>

     

    ===========================================

       protected void Reject_Click(object sender, EventArgs e)
            {

                string strID = ((System.Web.UI.WebControls.CommandEventArgs)(e)).CommandArgument.ToString();


                 

                int intResult = SqlHelper.ExecuteNonQuery("update [SAVLEAVE_OFFLINE].[dbo].[Leaves]  set LeaveStatus= 'Rejected' where ID= " + strID + "");
                RadGridApprove.Rebind();

                RadGridLeaveHistory.Rebind();
                RadNotification1.ContentIcon = "ok";
                RadNotification1.Text = "Leave Rejected!";
                RadNotification1.Show();

            }
    ========================================

    i want to get the textbox.text and use it in the sql command,

     thanks in advance for any help!

     

     

     

     

  3. Answer
    Eyup
    Admin
    Eyup avatar
    3699 posts

    Posted 16 Jul 2015 Link to this post

    Hi Yang,

    You can use the following approach to achieve this requirement:
    protected void ImageButton2_Command(object sender, CommandEventArgs e)
    {
        LinkButton button = sender as LinkButton;
        GridDataItem item = button.NamingContainer as GridDataItem;
        TextBox textBox = item["TemplateColumnTextBox"].FindControl("txtRejectReason") as TextBox;
     
        button.Text = textBox.Text;
    }

    Hope this helps. Please give it a try and let me know if it works for you.

    Regards,
    Eyup
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  4. Yang
    Yang avatar
    6 posts
    Member since:
    Oct 2012

    Posted 16 Jul 2015 in reply to Eyup Link to this post

    thanks Eyup, it works like magic
Back to Top