检索模板索引复选框ASP.Net C# [英] Retrieve the index of a template checkbox ASP.Net C#

查看:61
本文介绍了检索模板索引复选框ASP.Net C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有办法从ASP.net C#中的gridview中检索单元格的ID。我所做的是以编程方式绑定gridview。所以我添加了一个模板列,并通过工具箱添加了复选框。所以我需要做的是我需要通过GridView中的值名称创建文件。

任何建议或帮助都会有所帮助。

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.

推荐答案

这可能会对您有所帮助


试试这个..



Try this..

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







代码背后.....

void linkmodel_Click(Object sender,GridViewCommandEventArgs e)

{

if(e.CommandName ==id)

{

int id = e.commandargument.tostring();

}

}



nopte-使用适当的namin g conventation ......



我希望它能帮助你...




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.....


这篇关于检索模板索引复选框ASP.Net C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆