c# 怎么取得Repeater中文本框的值
前台:<asp:RepeaterID="Repeater1"runat="server"><ItemTemplate>车种:<asp:TextBoxID="TextBox...
前台:
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
车种:<asp:TextBox ID="TextBox1" runat="server" Text='<%# Eval("chezhong").ToString() %>'></asp:TextBox>
<br/>
车型:<asp:TextBox ID="TextBox2" runat="server" Text='<%# Eval("chexing").ToString() %>'></asp:TextBox><br />
</ItemTemplate>
</asp:Repeater>
后台:
protected void Button1_Click(object sender, EventArgs e)
{
string str = "";
str +=((TextBox)Repeater1.FindControl("TextBox1")).Text.Trim();
str+= "-"
str +=((TextBox)Repeater1.FindControl("TextBox2")).Text.Trim();
Response.Write(str);
}
错误是为将对象引用到实例 展开
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
车种:<asp:TextBox ID="TextBox1" runat="server" Text='<%# Eval("chezhong").ToString() %>'></asp:TextBox>
<br/>
车型:<asp:TextBox ID="TextBox2" runat="server" Text='<%# Eval("chexing").ToString() %>'></asp:TextBox><br />
</ItemTemplate>
</asp:Repeater>
后台:
protected void Button1_Click(object sender, EventArgs e)
{
string str = "";
str +=((TextBox)Repeater1.FindControl("TextBox1")).Text.Trim();
str+= "-"
str +=((TextBox)Repeater1.FindControl("TextBox2")).Text.Trim();
Response.Write(str);
}
错误是为将对象引用到实例 展开
6个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询