怎么在gridview上取radio这行的值
如何在gridview上取radio这行的值
我为gridview添加了一列radio,如何在页面上点击一个botton然后取gridview上选择了radio这行的值?
------解决方案--------------------
不知楼主的意思是不是想获取GridView每行的行号索引?
获取到索引,该行每列的值都可取到,
行号索引的获取方法:
int index = this.dataGridView1.CurrentRow.Index;
int index2 = this.dataGridView1.CurrentCell.OwningRow.Index;
string value = this.dataGridView1.Rows[index].Cells[0].Value.ToString();
根据楼主需要时使用index 还是 index2,然后就可获得每列的值。
<asp:GridView ID="GvData" runat="server" AutoGenerateColumns="False" BorderColor="#BBBBBB"
BorderWidth="1px" CssClass="tb" Width="600px">
<Columns>
<asp:TemplateField HeaderText="用户编号">
<ItemTemplate>
<asp:Label ID="userid" runat="server" Width="50px" Text='<%#Bind("userid") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="操作">
<ItemTemplate>
<asp:RadioButton ID="radButtonControl" GroupName="group1" runat="server" />
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
</Columns>
<EmptyDataRowStyle ForeColor="Red" HorizontalAlign="Center" />
</asp:GridView>
我为gridview添加了一列radio,如何在页面上点击一个botton然后取gridview上选择了radio这行的值?
------解决方案--------------------
不知楼主的意思是不是想获取GridView每行的行号索引?
获取到索引,该行每列的值都可取到,
行号索引的获取方法:
int index = this.dataGridView1.CurrentRow.Index;
int index2 = this.dataGridView1.CurrentCell.OwningRow.Index;
string value = this.dataGridView1.Rows[index].Cells[0].Value.ToString();
根据楼主需要时使用index 还是 index2,然后就可获得每列的值。