我有一个带有文本框和单选按钮列表和编辑按钮的表单视图,顺序如下
<asp:textbox id="tb1" runat="server" text='<%# Bind("DATE_1", "{0:d}") %>' />
<asp:calendarextender id="tb1_CalendarExtender" runat="server" targetcontrolid="tb1" />
<asp:textbox id="tb2" runat="server" text='<%# Bind("DATE_2", "{0:d}") %>' />
<asp:calendarextender id="tb2_CalendarExtender" runat="server" targetcontrolid="tb2" />
<asp:button id="EditButton" runat="server" causesvalidation="False" commandname="Edit" text="Edit" enabled='<%# CanEdit(Eval("DATE_1"), Eval("DATE_2")) %>' OnClick="EditButton_Click" />
<asp:radiobuttonlist id="rbl1" runat="server" repeatdirection="Horizontal" text='<%# Bind("DIAG_LL_APPROVAL") %>'>
<asp:ListItem>Approved</asp:ListItem>
<asp:ListItem>Rejected</asp:ListItem>
<asp:ListItem Selected="True">None</asp:ListItem>
</asp:radiobuttonlist>
<asp:textbox id="tb3" runat="server" text='<%# Bind("COMMENTS") %>' maxlength="1000"/>
当编辑按钮为 时,需要隐藏或禁用以及rbl1
是否tb3
有任何值(即) 。tb1
tb2
null
clicked
protected void EditButton_Click(object sender, EventArgs e)
{
TextBox t1 = FormViewName.FindControl("tb1") as TextBox;
TextBox t2 = FormViewName.FindControl("tb2") as TextBox;
RadioButtonList rbl = FormViewName.FindControl("rbl1") as RadioButtonList;
TextBox t3 = FormViewName.FindControl("tb3") as TextBox;
//if ("".Equals(tdcd) || "".Equals(tdrcd))
if (!string.IsNullOrEmpty(t1.Text) && !string.IsNullOrEmpty(t2.Text))
{
FormViewName.FindControl("rbl1").Visible = true;
FormViewName.FindControl("tb3").Visible = true;
}
else
{
FormViewName.FindControl("rbl1").Visible = false;
FormViewName.FindControl("tb3").Visible = false;
}
}
错误:对象引用未设置为对象的实例