如何在窗体视图控件中使用数据绑定禁用特定文本框 [英] how to disable particular text-box using databound in form-view control
问题描述
大家好,
这里我要禁用formview控件中的特定文本框,这里我完成onchangemode和一些方法但我发生错误消息,如objext引用没有设置对象的实例。 br />
这里我想要数据绑定方法来禁用特定文本框:
textbox id = txt1;
formview中的
::: ondatabound =frmview_Databound
请为此任务提供解决方案。
hi to all,
Here i want to disable particular textbox in formview control,here i done onchangemode and some method but i occur error message like objext reference not set an instance of an object.
Here i want databound method for disable particular textbox:
textbox id =txt1;
in formview :::ondatabound="frmview_Databound"
Kindly give solution for this task.
推荐答案
1。在您的aspx页面中添加formview,如下所示。
1. Add formview in your aspx page like below.
<asp:FormView ID="FormView1" runat="server" OnDataBound="FormView1_DataBound">
<ItemTemplate>
<table>
<tr>
<td>
<asp:TextBox ID="txt1" Text='<%# Eval("Name") %>' runat="server"></asp:TextBox>
</td>
</tr>
</table>
</ItemTemplate>
</asp:FormView>
2 。用于formview的aspx.cs中的fire数据绑定事件
2. Fire databound event in aspx.cs fiel for formview
protected void FormView1_DataBound(object sender, EventArgs e)
{
TextBox txt1 = (TextBox)FormView1.FindControl("txt1") as TextBox;
txt1.Visible = false;
}
3。绑定fromview像
3. bind fromview like
DataTable dt = new DataTable();
dt.Columns.Add("Name", typeof(string));
DataRow dtrow = dt.NewRow(); // Create New Row
dtrow["Name"] = "Mukesh"; //Bind Data to Columns
dt.Rows.Add(dtrow);
FormView1.DataSource = dt;
FormView1.DataBind();
这篇关于如何在窗体视图控件中使用数据绑定禁用特定文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!