从表单视图内的转发器内的文本字段获取数据
我想获取中继器内文本框的值,该中继器位于表单视图内,全部绑定到对象数据源。
<asp:FormView ID="FormView1" runat="server" AllowPaging="True"
DataKeyNames="Id" EnableViewState="False"
OnPageIndexChanging="FormView1_PageIndexChanging"
onitemupdated="FormView1_ItemUpdated"
OnItemUpdating="FormView1_ItemUpdating" ondatabound="FormView1_DataBound">
<ItemTemplate>
<asp:TextBox ID="txtProdName" runat="server" Text='<%#Eval("ManufacturerProductName") %>'></asp:TextBox>
<asp:Repeater ID="Repeater1" runat="server" DataSource='<%#DataBinder.Eval(Container.DataItem,"Distributors") %>'>
<ItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" ontextchanged="onTextChanged" Text='<%# DataBinder.Eval(Container.DataItem, "FobCost")%>'></asp:TextBox>
<asp:Repeater ID="Repeater2" runat="server" DataSource='<%# DataBinder.Eval(Container.DataItem,"PricingsheetWarehouses") %>'>
<ItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" ontextchanged="onTextChanged" Text='<%# DataBinder.Eval(Container.DataItem, "DeliveredCost")%>'></asp:TextBox>
</ItemTemplate>
</asp:Repeater>
</ItemTemplate>
</asp:Repeater>
</ItemTemplate>
</asp:FormView>
我得到 txtProdName 作为这个
TextBox t=FormView1.FindControl("txtProdname")as textBox;
,但我不能用它来获取 文本框 内的转发器它给我 null 有什么帮助吗?
i want to get the value of the textboxes inside the repeater which is inside a form view all binded to object datasource .
<asp:FormView ID="FormView1" runat="server" AllowPaging="True"
DataKeyNames="Id" EnableViewState="False"
OnPageIndexChanging="FormView1_PageIndexChanging"
onitemupdated="FormView1_ItemUpdated"
OnItemUpdating="FormView1_ItemUpdating" ondatabound="FormView1_DataBound">
<ItemTemplate>
<asp:TextBox ID="txtProdName" runat="server" Text='<%#Eval("ManufacturerProductName") %>'></asp:TextBox>
<asp:Repeater ID="Repeater1" runat="server" DataSource='<%#DataBinder.Eval(Container.DataItem,"Distributors") %>'>
<ItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" ontextchanged="onTextChanged" Text='<%# DataBinder.Eval(Container.DataItem, "FobCost")%>'></asp:TextBox>
<asp:Repeater ID="Repeater2" runat="server" DataSource='<%# DataBinder.Eval(Container.DataItem,"PricingsheetWarehouses") %>'>
<ItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" ontextchanged="onTextChanged" Text='<%# DataBinder.Eval(Container.DataItem, "DeliveredCost")%>'></asp:TextBox>
</ItemTemplate>
</asp:Repeater>
</ItemTemplate>
</asp:Repeater>
</ItemTemplate>
</asp:FormView>
i get txtProdName as this
TextBox t=FormView1.FindControl("txtProdname")as textBox;
but i cannot use it to get textboxes inside the repeater its giving me null
any help ??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您必须找到中继器本身内部的文本框,就像您使用
FormView1
所做的那样。You'll have to find the textbox inside of the repeater itself, just how you're doing it with the
FormView1
.使用递归搜索来查找控件,无论它有多深:
Use a recursive search to find the control no matter how deep it goes:
尝试
try