我在练习用Repeater控件做留言本,所有的空间都是绑定在Repeater里边的。留言本有留言和回复功能,我想在点击确认回复的时候把TextBox的值写入数据库,但现在我不知道如何获取TextBox中的值,望大虾解决。<asp:Repeater ID="Repeater1" runat="server" OnItemCommand="Repeater1_ItemCommand">
<ItemTemplate>
<table border=0 cellspacing=0>
<tr style="color:White;background-color:Green;">
<td>标题:<%#DataBinder.Eval(Container.DataItem,"cardTit")%>      
发表时间:<%#DataBinder.Eval(Container.DataItem,"sendTime")%>     
<asp:LinkButton ID=lbtnSend Text="回复" CommandName="showtext" runat=server></asp:LinkButton>
</td>
</tr>
<tr>
<td><%#DataBinder.Eval(Container.DataItem,"cardCon")%></td>
</tr>
<tr>
<td align=center><asp:TextBox ID="txthuifu" runat=server TextMode=multiline Width="385px" Height="194px" Visible=false></asp:TextBox></td>
</tr>
<tr>
<td align=center>
<asp:LinkButton ID="lbtnhuifu" runat=server Text="提交回复" CommandName="submit" Visible=false OnClick=LinkButton1_Click1></asp:LinkButton>   
<asp:LinkButton ID="lbtnquxiao" runat=server Text="取消回复" CommandName="qx" Visible=false></asp:LinkButton>
</td>
</tr>
</table>
</ItemTemplate>
</asp:Repeater>
怎么在后台代码的 protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
{
}事件中获取TextBox中的值
<ItemTemplate>
<table border=0 cellspacing=0>
<tr style="color:White;background-color:Green;">
<td>标题:<%#DataBinder.Eval(Container.DataItem,"cardTit")%>      
发表时间:<%#DataBinder.Eval(Container.DataItem,"sendTime")%>     
<asp:LinkButton ID=lbtnSend Text="回复" CommandName="showtext" runat=server></asp:LinkButton>
</td>
</tr>
<tr>
<td><%#DataBinder.Eval(Container.DataItem,"cardCon")%></td>
</tr>
<tr>
<td align=center><asp:TextBox ID="txthuifu" runat=server TextMode=multiline Width="385px" Height="194px" Visible=false></asp:TextBox></td>
</tr>
<tr>
<td align=center>
<asp:LinkButton ID="lbtnhuifu" runat=server Text="提交回复" CommandName="submit" Visible=false OnClick=LinkButton1_Click1></asp:LinkButton>   
<asp:LinkButton ID="lbtnquxiao" runat=server Text="取消回复" CommandName="qx" Visible=false></asp:LinkButton>
</td>
</tr>
</table>
</ItemTemplate>
</asp:Repeater>
怎么在后台代码的 protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
{
}事件中获取TextBox中的值
protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
{
TextBox tb = e.Item.FindControl("txthuifu") as TextBox;
if(tb != null)
{
string str = tb.Text;
}
}
//获取文本框中的值string huifu = ((TextBox)e.Item.FindControls("txthuifu")).Text;
{
TextBox tb =(TextBox)e.Item.FindControl("txthuifu");
string str=tb.Text;
}