gpt4 book ai didi

c# - 无法在 gridview 中访问 TextArea 中的文本

转载 作者:行者123 更新时间:2023-11-30 15:41:08 25 4
gpt4 key购买 nike

<ItemTemplate>
<textarea ID="TextArea1" TextMode="multiline" runat="server" cols="20" name="S1" rows="2"> </textarea><br />
<asp:Button ID="Button1" runat="server" CommandName = "comment" Text = "Comment"/>
</ItemTemplate>

SqlParameter par1 = new SqlParameter("@txt", SqlDbType.VarChar);
par1.Direction = ParameterDirection.Input;
par1.Value = Request.Form["TextArea1"];
com.Parameters.Add(par1);

我无法在 gridview 中的 textArea 中获取文本。我只是无法从后面的代码访问它。

我想将 textArea 中的文本分配给一个变量,但我无法访问 textArea

有什么想法吗?

最佳答案

我有一个示例 gridview,它可能对您有所帮助。

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" OnRowCommand="GridView1_RowCommand" 
AlternatingRowStyle-BackColor="#006699"
AlternatingRowStyle-ForeColor="#FFFFFF" onrowupdating="GridView1_RowUpdating">
<Columns >

<asp:BoundField HeaderText="Name" DataField="uname" />
<asp:BoundField HeaderText="Pass" DataField="upass"/>
<asp:TemplateField>
<HeaderTemplate>Active</HeaderTemplate>
<ItemTemplate >
<asp:TextBox ID="TextArea1" runat="server" TextMode="multiline" Text='<%#Eval("active")%>'></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:ButtonField CommandName="comment" Text="comment" />
</Columns>
</asp:GridView>

protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "comment")
{
string uname = "";
int index = Convert.ToInt32(e.CommandArgument);
GridViewRow row = GridView1.Rows[index];
TextBox txtbox1_val = (TextBox)row.FindControl("TextArea1");
uname = Server.HtmlDecode(row.Cells[1].Text.ToString());
//write code here
}
}

关于c# - 无法在 gridview 中访问 TextArea 中的文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8663249/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com