我们如何在运行时插入行 [英] How can we insert row at runtime
问题描述
我想为运行时而不是来自数据源的插入行创建gridview.
例如,我想获取诸如Pname,qty,rate
之类的记录
因此,当我提供此详细信息时,金额将自动在每一行中计算
最后,我计算了蚂蚁税的总额
所以我想在网格上进行上述处理.所以有人帮忙
所以我想在gridview中选择pname,它是像vb.net
这样的组合框列
任何帮助创建此gridview的人
I want to create gridview for insert rows at runtime not from datasource.
For example I want get the records like Pname,qty, rate
so when i give this details the amount is automatically calculated in each row
finally i calculate the total amount ant tax
So I want above process in on the grid. So anybody help
So the I want to select pname in gridview which is combobox column like vb.net
Anybody help for creating this gridview
推荐答案
像这样尝试
Try like this
//Create a DataTable instance
DataTable table = new DataTable();
//Create columns for this DataTable
DataColumn col1 = new DataColumn("ID");
//Define DataType of the Columns
col1.DataType = System.Type.GetType("System.Int");
//Add All These Columns into DataTable table
table.Columns.Add(col1);
//Create a Row in the DataTable table
DataRow row = table.NewRow();
//Fill All Columns with Data
row[col1] = 1;
//Add the Row into DataTable
table.Rows.Add(row);
//Bind this DataTable to a GridView
gvTest.DataSource = table;
gvTest.DataBind();
您需要根据需要进行更改.而在每个Page_Load DataTable上可能会丢失其值.因此,将数据表保留在会话中.
在某个地方看到了确切的要求和样品.您可以在Google上搜索并找到它.
You need to change this as per your needs. while on each Page_Load DataTable might lose its value. So keep the datatable in a session.
Has seen the exact requirement and sample somewhere. You can google it and find it out.
这篇关于我们如何在运行时插入行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!