数据表 [英] Data Table
问题描述
我有一个数据表dtValues,它通过单击按钮(添加)单击ddl,label,textbox中的值.此按钮将这些值添加到网格.我已经将数据表dtValues用作网格的数据源.
现在,我有另一个按钮提交",单击它时,将网格中的值保存到数据库中.我想要的是,在将记录保存到数据库之后,此按钮的单击事件会重置我的表单信息(这很好) ,但是当我输入下一条记录时,数据表仍包含先前记录中的值.我想将我的datatable(dtValues)和grid(gvOrders)重置为每次提交单击时都为空白.这就是我的click事件. .
I have a datatable dtValues which takes values from ddl,label,textbox on a button(Add) click.this button adds these values to the grid.I,ve used data table dtValues as datasource to grid.
Now,i have another button Submit,on its click the values from the grid Are saved to database.What i want is that my forms information is resetted on click event of this button after saving records to the database(which is happening just fine),but when i enter next records,the data table still contain the values from previous records.I want to reset my datatable(dtValues) and grid(gvOrders) to be blank on each submit click.this is what my click event looks like..
protected void btnSubmit_Click(object sender, EventArgs e)
{
if (gvOrders.Rows.Count > 0)
{
foreach (GridViewRow row in gvOrders.Rows)
{
InsertOrder(Convert.ToInt32(row.Cells[0].Text), Convert.ToInt32(row.Cells[3].Text));
}
}
txtAddress.Text = string.Empty;
txtName.Text = string.Empty;
txtPhone.Text = string.Empty;
txtQuantity.Text = string.Empty;
ddlSearchItems.SelectedIndex = -1;
lblActualPrice.Text = string.Empty;
lblSelectedItemPrice.Text = string.Empty;
gvOrders.Visible = false;
gvOrders.DataSource = null;
dtValues??????????;
}
我应该怎么写才能使我的数据表在每次单击按钮时都为空白?
有人可以帮我吗...
谢谢
Amit
what should i write to make my datatable blank on each button click?
Could someone help me with this...
Thanks
Amit
推荐答案
尝试在数据表中使用"Clear()"方法.清除其中的所有行.
问候,
Suresh
Hi,
Try using "Clear()" method in the datatable. It clears all the rows in it.
Regards,
Suresh
这篇关于数据表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!