Click here to Skip to main content
15,917,328 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In my webpage has GridView, I want one of my datafield is link field, When I click that field, I call the c# function which is in the cs file. How to do it. Please help me. And I pass the values of that field in particular row to that function.
Posted

1 solution

In design page :

XML
<ItemTemplate>
                                               <asp:LinkButton ID="LinkButton_File" runat="server" CommandName='<%# DataBinder.Eval(Container, "DataItem.FileName") %>'
                                                   CommandArgument='<%#Eval("FilePath") %>' Text='<%# Eval("FileName") %>'>
                                               </asp:LinkButton>
                                           </ItemTemplate>


And in code behind

C#
protected void EventFileDetailsItemCommand(object source, GridCommandEventArgs e)
        {
     if (e.CommandName == "DeleteFile")
                {
                    string[] commandArgs = e.CommandArgument.ToString().Split(new char[] { ',' });
                    var filePath = commandArgs[1].ToString();
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900