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

get value in GridTemplateColumn control from another GridTemplateColumn control click

3 Answers 80 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Yang
Top achievements
Rank 1
Yang asked on 13 Jul 2015, 06:49 AM
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

3 Answers, 1 is accepted

Sort by
0
Yang
Top achievements
Rank 1
answered on 13 Jul 2015, 06:54 AM

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!

 

 

 

 

0
Accepted
Eyup
Telerik team
answered on 16 Jul 2015, 05:54 AM
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
0
Yang
Top achievements
Rank 1
answered on 17 Jul 2015, 02:18 AM
thanks Eyup, it works like magic
Tags
Grid
Asked by
Yang
Top achievements
Rank 1
Answers by
Yang
Top achievements
Rank 1
Eyup
Telerik team
Share this question
or