Gridview中RadioButtonList联动中“
未将对象引用设置到对象的实例”
建站中,点击更新时怀疑RadioButtonList取值没成功,望各位大大帮忙看看
源错误:
行 147: {
行 148: string id = e.CommandArgument.ToString();
行 149: string audit = auditrbl.SelectedItem.Value.ToString();
行 150: string level = levelrbl.SelectedItem.Value.ToString();
行 151: string str = "UPDATE T_Member SET [F_Audit]=" + audit + ",[F_Level]=" + level + ";";
源文件: j:\Sam‘s Work1\MemberMain.aspx.cs 行: 149
堆栈跟踪:
[NullReferenceException: 未将对象引用设置到对象的实例。] MemberMain.GridView_RowCommand(Object sender, GridViewCommandEventArgs e) in j:\Sam‘s Work1\MemberMain.aspx.cs:149
System.Web.UI.WebControls.GridView.OnRowCommand(GridViewCommandEventArgs e) +108
System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +112
System.Web.UI.WebControls.GridView.OnBubbleEvent(Object source, EventArgs e) +95
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
System.Web.UI.WebControls.GridViewRow.OnBubbleEvent(Object source, EventArgs e) +123
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e) +118
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +166
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565
HTML code
<asp:TemplateField HeaderText="审核状态">
<ItemTemplate>
<asp:Label ID="lblaudit" runat="server" Text='<%# Eval("F_Audit") %>' />
</ItemTemplate>
<EditItemTemplate>
<asp:RadioButtonList ID="AuditRBL" runat="server" RepeatDirection="Vertical" AutoPostBack="true" AppendDataBoundItems="true">
<asp:ListItem Value="0" Text="未通过"></asp:ListItem>
<asp:ListItem Value="1" Text="已通过"></asp:ListItem>
</asp:RadioButtonList>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="级别">
<ItemTemplate>
<asp:Label ID="lbllevel" runat="server" Text='<%# Eval("F_Level") %>' ></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:RadioButtonList ID="LevelRBL" runat="server" RepeatDirection="Horizontal" AutoPostBack="true" AppendDataBoundItems="true">
<asp:ListItem Value="0" Text="普通会员"></asp:ListItem>