在gridview中想要选中的单选按钮文本。 [英] In gridview want the selected radio button text.
本文介绍了在gridview中想要选中的单选按钮文本。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个gridview。在那我有四个单选按钮及其组名。当我从gridview中选择任何一个单选按钮时,我想要那个单选按钮的受尊重文本。
解决方案
你可以在gridview的ItemTemplate中使用RadioButtonList,在gridview的RowDataBound事件中,你可以绑定列表中的项目。
< itemtemplate >
< asp:RadioButtonList id = rbList runat = server AutoPostBack = false > < / asp:RadioButtonList >
< / itemtemplate >
protected void gridview1_RowDataBound( object sender,GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
RadioButtonList list =(RadioButtonList)e.Row.FindControl( rbList跨度>);
list.DataSource = objDT; // 您的数据表为数据源
list.DataBind();
}
}
受保护 void lbtnsubmit_Click( object sender,EventArgs e)
{
for ( int i = 0 ; i < GridView1.Rows.Count; i ++)
{
RadioButtonList rblist =(GridView1.Rows [i] .FindControl( rbList)) as RadioButtonList;
if (rblist.SelectedItem!= null )
{
asnw.Text = rbList.SelectedItem.Text;
}
}
}
希望有帮助
< blockquote>
Gridview中的分组单选按钮 [ ^ ]
GridView控件内的RadioButtons [ ^ ]
使用这些链接它会帮助你。
谢谢
Neha Sharma
I have a gridview. In that I have four radio button with its group name. when I select any one radio button from gridview, I want the respected text of that radio button.
解决方案
Hi,
you can use RadioButtonList in the ItemTemplate of the gridview and in RowDataBound event of the gridview, you can bind the items of the list.
<itemtemplate> <asp:RadioButtonList id="rbList" runat="server" AutoPostBack="false"></asp:RadioButtonList> </itemtemplate>
protected void gridview1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { RadioButtonList list = (RadioButtonList)e.Row.FindControl("rbList"); list.DataSource = objDT; //your datatable as datasource list.DataBind(); } }
protected void lbtnsubmit_Click(object sender, EventArgs e) { for (int i = 0; i < GridView1.Rows.Count; i++) { RadioButtonList rblist = (GridView1.Rows[i].FindControl("rbList")) as RadioButtonList; if (rblist.SelectedItem != null) { asnw.Text = rbList.SelectedItem.Text; } } }
hope it helps
Hi ,
Grouped Radio Buttons in Gridview[^]
RadioButtons inside a GridView control[^]
go with these links it ll help you.
Thanks
Neha Sharma
这篇关于在gridview中想要选中的单选按钮文本。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文