问题描述
你好,
我已将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();
}
}
int index = Convert.ToInt32(e.CommandArgument);
GridViewRow row = GridView1.Rows[index];
lblassinmentno.Text = row.Cells[1].Text;
这篇关于在GridView中选择一个值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!