Click here to Skip to main content
15,896,528 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, I would like to to know if there is a way to retrieve the ID of a cell from the gridview in ASP.net C#. What I do is I bind the gridview programmatically. So I added a a template column and added check box to it via the toolbox. So what I need to do is that I need to create files by the name of a value in the GridView.
Any suggestions or help will be helped.
Posted

 
Share this answer
 
Try this..

XML
<asp:TemplateField>
     <ItemTemplate>
         <asp:LinkButton runat="server" ID="linkmodel" Text='<%#Eval("MenuItem") %>'
                         CommandArgument='<%#Eval("CommandName") %>'
                         OnCommand="linkmodel_Click; CommandName="id"
                         OnClientClick="return confirm('Are You Sure')">
         </asp:LinkButton>
     </ItemTemplate>
</asp:TemplateField>



In code behind.....
void linkmodel_Click(Object sender, GridViewCommandEventArgs e)
{
if(e.CommandName=="id")
{
int id=e.commandargument.tostring();
}
}

nopte-use proper naming conventation......

I hope it will helpfull 4 u.....
 
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