如何在GridView中写入值 [英] How to write values in GridView
问题描述
大家好,
我是ASP.Net应用程序的新手.我的页面上有一些TextBoxes
和GridView
.我要做的是将文本框中的值保存到发票表"中,并且希望通过GridView保存发票明细"值,但是GridView的行为是 readonly.我想首先在GridView中插入值.但是它表现为 ReadOnly
在Windows应用程序表单中,我可以在DataGridView中写入(与许多条记录相同),然后单击保存"按钮,然后将文本框值保存在发票表"中. DataGrid值保存在发票明细表中.使用这个
Hello all,
I am new to ASP.Net Application. I have a page with some TextBoxes
and a GridView
. What I have Done is I took the Values from Textboxes save into Invoice Table and i want to save Invoice Detail values through GridView, But the GridView behave readonly.I want to Insert values firstly in GridView. But it Behaves ReadOnly
In Windows Application form i can write in DataGridView (As many Record) and click save Button then textboxes value save in Invoice table & DataGrid Values save in Invoice Detail Table. using this
foreach (DataGridViewRow dr in dgview.Rows)
{
if (dr.Cells[1].Value != null)
{
CMS.Components.WEB.Invoice_Detail objd = new CMS.Components.WEB.Invoice_Detail();
objd.Description = Convert.ToString(dr.Cells["Description"].Value);
objd.Quantity = Convert.ToString(dr.Cells[2].Value);
如何在ASP.Net应用程序中使用此senerio?
当我单击插入"按钮,然后将textBoxes值保存在发票表"中并且将发票明细"值(所有行,然后是1)保存在Inv_Detail表中时,是否还有其他方法?
如果可能,请给我发送示例项目吗?
How can i use this senerio in ASP.Net Application?
Is there any other way when i click INSERT Button then textBoxes values save in Invoice Table and Invoice Detail values(All Row, More then 1) save in Inv_Detail Table only one Insert Button Click?
If May be Possible send me sample project?
推荐答案
在asp.net中,可以在网格视图中添加InsertItemTemplate以在网格视图中接受数据.
请在这里查看:
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.templatefield.insertitemtemplate.aspx
尽管以上链接中的示例在DetailsView中具有inertertitemtemplate,但您仍然可以在GridView中应用相同的概念.
In asp.net, you could add InsertItemTemplate in grid view to accept data in the grid view.
Pleas see here:
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.templatefield.insertitemtemplate.aspx
Although the example in above link has inrertitemtemplate in DetailsView you can still apply the same concept in GridView.
这篇关于如何在GridView中写入值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!