且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何将文本框中的数据/记录插入到datagrid中

更新时间:2023-11-18 23:30:46

protected void Button1_Click(object sender, EventArgs e)
{
// code to insert the textbox value.
   DataGrid1.DataBind();
}



这可能对您有帮助
在此处检查 [



This may help you
check here[^]


服务器端:
1.在单击按钮事件时,获取文本框的数据.
2.保存到数据库
3.获取Grid的数据(现在应该包含输入的数据)
4.使用新数据作为数据源
缺点:往返,但数据仍然保存并保存.

客户端:
1.在onclientclick事件按钮上,使用Javascript方法获取文本框的数据.
2.获取网格JS方法中的网格行
3.访问要编辑的单元格.替换文本框一中的值.
缺点:数据未发送到服务器,因此未保存.虽然很快.
Server side:
1. On button click event, get the data of textbox.
2. Save in DB
3. Get data for Grid (this should now contain the entered data)
4. Use the new data as datasource
Downside: A round trip, but data persisted and saved.

Client Side:
1. On button onclientclick event, get the data of textbox in Javascript method.
2. Get the grid & grid row in JS method
3. Access the cell that you want to edit. Replace the value from textbox one.
Downside: Data not sent to server and thus not saved. Though it''s fast.