在GridView中选择一个值

编程入门 行业动态 更新时间:2024-10-26 12:31:11
本文介绍了在GridView中选择一个值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

你好, 我已将GridView添加到我的Web表单中,并且希望在运行时从中检索一个值. gridview位于UpdatePanel内部.我将AutoGenerateSelectButton属性设置为true.但是,当我单击自动生成的按钮时,它不会触发任何事件.这些按钮就像已禁用,但不是. 请帮我解决这个问题. 提前谢谢. 祝你有美好的一天!

Hello, I have added a GridView to my web form and I want to retrieve a value from it during runtime. The gridview is located inside an UpdatePanel. I set the AutoGenerateSelectButton property to true. But when I click on an auto generated button it doesn''t fire any events. The buttons are like disabled but they are not. Please help me to resolve this. Thanks in advance. Have a nice day!

推荐答案

hi , you can use loop .

foreach (GridViewRow item in GridView1.Rows) { string test= item.Cells[2].Text; }

foreach (GridViewRow item in GridView1.Rows) { string str= item.Cells[i].Text; }

或 您可以在行中添加ItemTemplate,在模板中添加按钮.添加绑定参数"CommandName"和"CommandArgument".

Or you can add a ItemTemplate to Rows and add a Button to Template.Add Bind the parameter "CommandName " and "CommandArgument".

protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Detail") { e.CommandArgument.ToString(); } }

使用行命令事件 Use rowcommand event int index = Convert.ToInt32(e.CommandArgument); GridViewRow row = GridView1.Rows[index]; lblassinmentno.Text = row.Cells[1].Text;

更多推荐

在GridView中选择一个值

本文发布于:2023-10-17 06:15:39,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1500008.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:GridView

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!