如何将表单条目添加到gridview中 [英] how to add form entries into gridview

查看:97
本文介绍了如何将表单条目添加到gridview中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户填写所有上述控件时,表单中包含4个文本框和3个下拉列表,然后他将选择按钮(添加)。然后它将出现在gridview中,用户将在gridview中删除。当用户最后保存什么数据gridview包含它将移动到数据库,

任何想法,我不期望整个编码jus需要线程..

In the form contains 4 textbox and 3 dropdown when user filled all the above controls then he will choose button(add). Then it will appear into gridview from there user will delete with in gridview. when user give save finally what data gridview contains it will move to the database,
any idea about this i am not expecting entire coding jus need the thread..

推荐答案

试试这个:



Try This:

DataTable table = new DataTable();

DataColumn col1 = new DataColumn("ID");
DataColumn col2 = new DataColumn("Name");
DataColumn col3 = new DataColumn("Checked");

col1.DataType = System.Type.GetType("System.Int" );
col2.DataType = System.Type.GetType("System.String" );
col3.DataType = System.Type.GetType("System.Boolean");

table.Columns.Add(col1);
table.Columns.Add(col2);
table.Columns.Add(col3);


DataRow row = table.NewRow();



row[col1] = textBox1.Text;
row[col2] = DropDown1.SelectedValue;
row[col3] = CheckBox1.checked;


table.Rows.Add(row);

GridView gvTest=new GridView();
gvTest.DataSource = table;
gvTest.DataBind();


这篇关于如何将表单条目添加到gridview中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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