Getting the text of label from OnClick event

I have an itemTemplate like below. It has an OnClick Event. In the onClick event, i down the dcoument.

But, I need to get the name of the document. In the OnItemDataBound, I can do this to get the label's text:
GridDataItem item = (GridDataItem)e.Item;
LinkButton lblResumeDoc = (LinkButton)item["TemplateColumn"].FindControl("hlResumeName");

But how can I do it in the OnClick event?
 protected void Resume_OnClick(object sender, EventArgs e)
    {
        //LinkButton lblResumeDoc = (LinkButton)item["TemplateColumn"].FindControl("hlResumeName");
        string filename = "timesheet6.docx"; //hardcoded but how can I get it??

...
  }
       

<telerik:GridTemplateColumn HeaderText="R&eacute;sum&eacute;">
                   <ItemTemplate>
                                           <asp:LinkButton ID="hlResumeName" OnClick="Resume_OnClick"   runat="server" Text='<%# Eval("Resume") %>'></asp:LinkButton>

                   </ItemTemplate>
                </telerik:GridTemplateColumn>

Open in new window

LVL 8
CamilliaAsked:
Who is Participating?
 
strickddConnect With a Mentor Commented:
Change the ItemTemplate to be a button field and use the RowCommand event.

<asp:ButtonField ButtonType="LinkButton" Text='<%# Eval("Resume") %>' CommandName="Resume" />


protected void CourseList_RowCommand(object sender, GridViewCommandEventArgs e)
      {
            if (e.CommandName == "Resume")
            {
                  int rowId = Convert.ToInt(e.CommandArgument);
                        TextBox tb = (TextBox)MyGridView.Rows[rowId].FindControl("MyTextBoxID");
            }
      }
0
 
CamilliaAuthor Commented:
let me see, Thanks.
0
 
CamilliaAuthor Commented:
I dont need the Resume_OnClick onclick event anymore?

ButtonField doesnt exist but i still can use CommandName:

<telerik:GridTemplateColumn HeaderText="R&eacute;sum&eacute;">
                   <ItemTemplate>
                      <asp:Label runat="server" ID="lblResumeText" Text='<%# Eval("Resume") %>' /> 
                      <asp:LinkButton ID="hlResumeName" OnClick="Resume_OnClick"  CommandName="Resume"   runat="server" Text='<%# Eval("Resume") %>'></asp:LinkButton>
                      
                   </ItemTemplate>
                </telerik:GridTemplateColumn>

Open in new window

0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
CamilliaAuthor Commented:
I'm using Telerik RadGrid. I dont see a RowCommand. When user clicks on the linkbutton or fieldbutton whatever, i want to get the text of that column...

I dont think even with your method that would work..where's the onClick event??
0
 
CamilliaAuthor Commented:
maybe i have to use another event for Telerik radgrid??
0
 
CamilliaAuthor Commented:
yeah, i think i have to use OnItemCommand to duplicate what u have:

http://demos.mcmscontrols.com/ASPNET/Grid/Examples/Client/PostbackOnClientRowClick/DefaultCS.aspx
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.