将Dynamic Created Gridview中的数据保存到DataBase [英] Save data from Dynamic Created Gridview to DataBase
本文介绍了将Dynamic Created Gridview中的数据保存到DataBase的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨,,
我用后面的代码创建了一个网格视图
我的要求是基于选择列表我需要创建没有网格视图
例如我的选择是2我需要创建两个gridview。这是示例代码我创建没有gridviews thats罚款
现在问题在于用户在每个gridview中输入一些值
i想保存那些gridview数据到数据库。
请帮帮我
预付结转
Hi,,
I created a grid view from code behind
My requirement is based on selection list i need to create that no of gridviews
for example my selection is 2 i need to create two gridview .this is sample code i created no of gridviews thats fine
now the problem is here the user enters some values in each gridview
i want to save those gridview data into database.
please help me
Thanks in Advance
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnbackupsheet.Click
Dim totalcount = CheckBoxList1.Items.Cast(Of ListItem)().Where(Function(item) item.Selected).Count()
Dim NumberOfGrids As Integer = totalcount
For i As Integer = 0 To NumberOfGrids - 1
Dim ds As New DataSet
ds = Session("query31ds")
Dim dt1 As New DataTable
dt1 = ds.Tables(0)
Dim gv As New GridView()
gv.AutoGenerateColumns = False
Dim bf As New BoundField
bf.HeaderText = "Name"
bf.DataField = "Name"
gv.Columns.Add(bf)
Dim createStartDate As New Date(Now.Year, Now.Month, 1)
Dim count = dt1.Columns.Count
For j = 1 To count - 1
' Here is template column portion
Dim TmpCol As New TemplateField()
Dim date1 As Date
date1 = createStartDate.AddDays(j - 1).ToShortDateString()
TmpCol.HeaderText = date1.ToString("dd-MMM")
TmpCol.ItemTemplate = New TemplateHandler()
gv.Columns.Add(TmpCol)
Next
gv.DataSource = Session("query31ds")
gv.DataBind()
GridviewsContainer.Controls.Add(gv)
Next
End Sub
推荐答案
只需收集来自不同网格的数据然后插入到db表中。
Simply gather data from different grids & then insert in the db table.
这篇关于将Dynamic Created Gridview中的数据保存到DataBase的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文