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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

strickddCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
JavaScript Best Practices

Save hours in development time and avoid common mistakes by learning the best practices to use for JavaScript.

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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.