取GridView的模板中RadioButtonList的id时,提示NewSelectedIndex没有定义,怎么办?
代码为RadioButtonListrbl=GridView1.Rows[e.NewSelectedIndex].Cells[5].FindControl("RadioB...
代码为RadioButtonList rbl = GridView1.Rows[e.NewSelectedIndex].Cells[5].FindControl("RadioButtonList1") as RadioButtonList;
.aspx文件中的代码为<asp:TemplateField>
<ItemTemplate>
<asp:RadioButtonList ID="RadioButtonList1" runat="server" AutoPostBack="True"
onselectedindexchanged="RadioButtonList1_SelectedIndexChanged">
<asp:ListItem Value="A"></asp:ListItem>
<asp:ListItem Value="B"></asp:ListItem>
<asp:ListItem Value="C"></asp:ListItem>
<asp:ListItem Value="D"></asp:ListItem>
</asp:RadioButtonList>
</ItemTemplate>
<ControlStyle Width="100px" />
<ItemStyle Width="100px" />
</asp:TemplateField>,请高手帮忙,谢谢啦。 展开
.aspx文件中的代码为<asp:TemplateField>
<ItemTemplate>
<asp:RadioButtonList ID="RadioButtonList1" runat="server" AutoPostBack="True"
onselectedindexchanged="RadioButtonList1_SelectedIndexChanged">
<asp:ListItem Value="A"></asp:ListItem>
<asp:ListItem Value="B"></asp:ListItem>
<asp:ListItem Value="C"></asp:ListItem>
<asp:ListItem Value="D"></asp:ListItem>
</asp:RadioButtonList>
</ItemTemplate>
<ControlStyle Width="100px" />
<ItemStyle Width="100px" />
</asp:TemplateField>,请高手帮忙,谢谢啦。 展开
1个回答
展开全部
你在哪个事件里写的啊
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
这个地方的e基本上没什么用,除非取父级然后强制转换
}
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
e.CommandArgument;
e.CommandName;
e.CommandSource;
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
e.Row.RowIndex;
}
你自己看看应该明白了
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
这个地方的e基本上没什么用,除非取父级然后强制转换
}
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
e.CommandArgument;
e.CommandName;
e.CommandSource;
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
e.Row.RowIndex;
}
你自己看看应该明白了
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询