gridview中嵌套Button控件
来源:互联网 发布:肖像剪纸软件 编辑:程序博客网 时间:2024/05/20 19:17
这个是在网上找的一片文章,自己试着调试了一下,但并未调试成功,以后有时间了在调试吧!大家谁调试出来也可以发布出来分享。
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (e.Row.FindControl("Button1") != null)
{
Button btn = (Button)e.Row.FindControl("Button1");
btn.Click += new EventHandler(btn_Click);
}
}
}
private void btn_Click(object sender, EventArgs e)
{
Button btn = (Button)sender;
GridViewRow gvr = (GridViewRow)btn.Parent.Parent;
string pk = GridView1.DataKeys[gvr.RowIndex].Value.ToString();
this.Label1.Text = pk;
http://topic.csdn.net/u/20080401/17/690f559d-7dcc-457e-bdec-6e01351bdbfe.html
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="Button1" runat="server" CommandName="MyCommand" Text="Button" />
</ItemTemplate>
</asp:TemplateField>
===============================================
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "MyCommand")
{
Button button = (Button)e.CommandSource;
GridViewRow row =(GridViewRow)button.Parent.Parent;
string a = row.Cells[1].Text.ToString();//获得第一个单元格的值
string b = this.GridView1.DataKeys[row.DataItemIndex].Values[0];//获得DataKeys的值
}
}
- gridview中嵌套Button控件
- gridview中嵌套button控件获取值
- GridView中嵌套GridView
- GridView中嵌套GridView
- android GridView控件嵌套GridView
- GridView中Button传值
- ListView 中嵌套 GridView
- ListView中嵌套gridview
- listview中嵌套gridview
- ASP.NET中GridView中嵌套GridView
- GridView里的Button控件用法
- GridView中嵌套Repeater方法
- GridView中嵌套Repeater方法
- ScrollView中嵌套ListView,GridView
- SrollView中嵌套GridView冲突
- 在SrollView中嵌套GridView
- android中Button控件
- asp.net GridView 中TemplateField中的Button或buttonlink控件点击后获得选中的GridView 行号
- Windows NT 与 Windows 的区别
- ASP.NET中防止页面多次提交的代码实现
- mysql常用命令
- C# Upload File 这个比较有价值
- oracle sql plus命令大全【转】
- gridview中嵌套Button控件
- C_艺术字编写
- 天极网的面试题,大家有时间做做,考的很基础,所有平常要多积累些基础知识
- Project Euler Problem 60
- 猫和老鼠
- midl : command line error MIDL1004 : cannot execute C preprocessor cl.exe
- Fedora下Samba(smb)配置方法
- 【开关电源】 基本结构和3大辐射源
- Django笔记-Template