从文本框向gridview添加文本,值 [英] adding text,value to gridview from textbox
本文介绍了从文本框向gridview添加文本,值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<asp:gridview id="GridView1" runat="server" autogeneratecolumns="False" backcolor="White"
BorderColor="#E7E7FF" BorderStyle="None" BorderWidth="1px" CellPadding="3" GridLines="Horizontal"
Style="z-index: 100; left: 187px; position: absolute; top: 195px" Width="50%">
<footerstyle backcolor="#B5C7DE" forecolor="#4A3C8C" />
<columns>
<asp:templatefield headertext="cid">
<itemtemplate><asp:textbox id="tt" runat="server"></asp:textbox> </itemtemplate>
</asp:templatefield>
<asp:templatefield headertext="name">
<itemtemplate><asp:textbox id="tt1" runat="server"></asp:textbox> </itemtemplate></asp:templatefield>
<asp:templatefield headertext="age">
<itemtemplate><asp:textbox id="tt2" runat="server"></asp:textbox> </itemtemplate></asp:templatefield>
<asp:templatefield showheader="False">
<edititemtemplate>
<asp:linkbutton id="LinkButton1" runat="server" causesvalidation="True" commandname="Update" Text="Update"></asp:linkbutton>
<asp:linkbutton id="LinkButton2" runat="server" causesvalidation="False" commandname="Cancel" Text="Cancel"></asp:linkbutton>
</edititemtemplate>
<itemtemplate>
<asp:linkbutton id="LinkButton1" runat="server" causesvalidation="False" commandname="Edit" Text="Edit"></asp:linkbutton>
</itemtemplate>
</asp:templatefield>
</columns>
<rowstyle backcolor="#E7E7FF" forecolor="#4A3C8C" />
<selectedrowstyle backcolor="#738A9C" font-bold="True" forecolor="#F7F7F7" />
<pagerstyle backcolor="#E7E7FF" forecolor="#4A3C8C" horizontalalign="Right" />
<headerstyle backcolor="#4A3C8C" font-bold="True" forecolor="#F7F7F7" />
<alternatingrowstyle backcolor="#F7F7F7" />
</asp:gridview>
我有这样的gridview,现在我想将文本框中的文本分配给
在运行时出现在gridview中的文本框
i have gridview like this and now i want to assign text from textbox to
textbox present in gridview at runtime
推荐答案
//vb.net代码
私有子TestGrid_SaveCommand(按对象作为ByVal源,按System.Web.UI.WebControls.DataGridCommandEventArgs作为ByVal e)处理TestGrid.UpdateCommand
strSql.Remove(0,strSql.Length)
strSql.Append("update test_table set")
strSql.Append("Test_Name ="& CType(e.Item.FindControl(" txtOnEdit),TextBox).Text&"")
strSql.Append("where")
strSql.Append("Test_Id ="& TestGrid.DataKeys.Item(e.Item.ItemIndex)&"")
//执行上述查询以更新值
结束Sub
//vb.net code
Private Sub TestGrid_SaveCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles TestGrid.UpdateCommand
strSql.Remove(0, strSql.Length)
strSql.Append("update test_table set ")
strSql.Append("Test_Name=''" & CType(e.Item.FindControl("txtOnEdit"), TextBox).Text & "''")
strSql.Append("where ")
strSql.Append("Test_Id=''" & TestGrid.DataKeys.Item(e.Item.ItemIndex) & "''")
//excute the above query to update values
End Sub
这篇关于从文本框向gridview添加文本,值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文