如何从选定单选按钮的网格视图中获取值 [英] How to Get value from Grid View for the Selected Radio Button
本文介绍了如何从选定单选按钮的网格视图中获取值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何从网格视图中的选定单选按钮获取特定单元格值到文本框。
可以帮助吗?
How to get Particular Cell Value into Text Box from Selected Radio Button in Grid View.
Can U Help?
推荐答案
让你的gridview id是gv_form,你的textbox id是textbox1,你的radiobutton id是rdb1然后使用下面的代码来获取列名Column1的值
Lets your gridview id is gv_form, your textbox id is textbox1 and your radiobutton id is rdb1 then use the following code to get the values of column name "Column1"
for (int i = 0; i <= gv_form.Rows[i].Count - 1; i++)
{
GridViewRow row = gv_form.Rows[i];
RadioButton rdb = (RadioButton)row.FindControl("rdb1");
if (rdb.Checked == true)
{
textbox1.text = row[i]["Column1"].ToString();
}
}
谢谢&问候,
BlueSathish
Thanks & Regards,
BlueSathish
创建一个radiobutton CheckedChanged事件通过它的命名容器获取gridview行
然后通过它找到你的单元格值index
protected void RadioButton1_CheckedChanged(object sender,EventArgs e)
{
RadioButton btn =(RadioButton)发件人;
//获取包含此按钮的行
GridViewRow gvr =(GridViewRow)btn.NamingContainer;
string cellValue = gvr.Cells [ 0]。文字;
}
Create a radiobutton CheckedChanged event get the gridview row by it's naming container
And find your cell value by it's index
protected void RadioButton1_CheckedChanged(object sender, EventArgs e)
{
RadioButton btn = (RadioButton)sender;
//Get the row that contains this button
GridViewRow gvr = (GridViewRow)btn.NamingContainer;
string cellValue = gvr.Cells[0].Text;
}
这篇关于如何从选定单选按钮的网格视图中获取值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文