拖曳在gridview中插入行 [英] tow to insert row in gridview

查看:70
本文介绍了拖曳在gridview中插入行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何更好的文本框中的插入行或gridview中的stright

any better insert row from textboxes or stright in gridview

推荐答案

试试这个:

Try this:
DataTable Dt = (DataTable)(GridView1.DataSource);
 Dt.Rows.Add(Dt.NewRow());
 Dt.Rows[Dt.Rows.count-1]["ColName"]=txtProd.Text;
 Dt.Rows[Dt.Rows.count-1]["OtherColName"]=txtCatgeory.Text;
 Dt.Rows[Dt.Rows.count-1]["MyColumn"]=txtDescription.Text;
 Dt.AcceptChanges();
 
 GridView1.EditIndex = Dt.Rows.count-1;
 GridView1.DataSource = Dt;
 GridView1.DataBind();


如果我能理解你的问题,你可能会问,哪个是更好的选择



a)在文本框中添加数据,然后当用户保存该数据时,将新行添加到gridview。

b)允许用户直接在网格视图中添加行(更好称为网格的内联编辑)





要回答这个问题,选择实际上取决于网格的添加/编辑功能的使用。

如果用户只关心查看数据而很少需要操作数据(添加/编辑),那么选择a会更好。



否则,如果以正确的方式实施,选择'b'会更好。
If I could understand your question, you probably meant to ask, which is better choice

a) Add data in text boxes and then when user saves that data add new row to gridview.
b) Allow user to directly add rows in grid view (better known as inline editing of grid)


To answer this, the choice really depend on usage of Add/Edit functionality for a grid.
If user are only concerned in viewing the data and are rarely required to manipulate the data (add/edit) then choice 'a' is better.

Otherwise choice 'b' is better if implemented in correct way.


这篇关于拖曳在gridview中插入行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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