如何将文本框中的数据/记录插入到datagrid中 [英] how to insert data/record from textbox into datagrid

查看:72
本文介绍了如何将文本框中的数据/记录插入到datagrid中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ASP网页,并且想要插入输入到文本框中的数据,以便在单击按钮时将其插入到同一页面上的数据网格中.:confused:

预先感谢.

Hi , i have a asp web page and want to insert the data that is entered into a textbox to be inserted into a datagrid on the same page when a button is clicked.:confused:

Thanks in advance.

推荐答案

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.


这篇关于如何将文本框中的数据/记录插入到datagrid中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆