<InsertItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("ProductId") %>'>
</asp:TextBox>
</InsertItemTemplate>
如何将值传递给绑定(“ProductId”)?更具体地讲:如何为asp.net中的bind()指定值<插入模板>
Request.QueryString["ProductId"]
<InsertItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("ProductId") %>'>
</asp:TextBox>
</InsertItemTemplate>
如何将值传递给绑定(“ProductId”)?更具体地讲:如何为asp.net中的bind()指定值<插入模板>
Request.QueryString["ProductId"]
编辑:
把它与原来的绑定,但添加OnDataBinding
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("ProductId") %>'
OnDataBinding = "TextBox1_OnDataBinding"></asp:TextBox>
和
protected void TextBox1_OnDataBinding(object sender, EventArgs e)
{
(sender as TextBox).Text = Request.QueryString["ProductId"];
}
除了
<asp:TextBox ID="TextBox1" runat="server" Text='<%#Request.QueryString["ProductID"]%>' />
您需要处理数据源的OnInserting事件并使用querystring参数设置值。
您必须在DataBoundControl的DataBound事件(中继器/ gv等)中显式设置TextBox值。
我试过,它实际上并没有将值传递给objectdatasource使用的对象的参数。 – Odnxe 2011-03-22 18:06:01
@Odnxe您试图在文本框中显示来自QueryString的ProductId,并且您希望在保存时将文本框的值发送回数据源? – 2011-03-22 18:09:27
@StackOverflowException - 是的基本上我想从URL参数“ProductId =?”中取值并将该值分配给文本框,该文本框通过bind()连接到数据库 – Odnxe 2011-03-22 18:15:21