hi-
I'v got a page where a user enters some data in text boxes, etc, the clicks add and should add to a dynamically created table below. I figured that by having the table be a datagrid control and using a dataset in code-behind, I'd have this covered. However I'm not sure how to access the stuff. I figured that if the page hadn't posted back (ie the when its initially loaded), i'd create a blank dataset, bind it to the datagrid, and go from there. but when I went to code it:
... it doesn't let me at the row and databind out of the if statement... both the dTable and ds are "undeclared". I didn't realize this happened inside if statements. what my goal is, is when the add button is clicked, I update the dataset, and rebind it... but there must be some intricacies that I'm unaware of.
Can someone shed some light?
Thanks,
Marc
I'v got a page where a user enters some data in text boxes, etc, the clicks add and should add to a dynamically created table below. I figured that by having the table be a datagrid control and using a dataset in code-behind, I'd have this covered. However I'm not sure how to access the stuff. I figured that if the page hadn't posted back (ie the when its initially loaded), i'd create a blank dataset, bind it to the datagrid, and go from there. but when I went to code it:
Code:
If Not IsPostBack Then
Dim ds As New DataSet("MeetingDetails")
Dim dTable As New DataTable("Details")
dTable.Columns.Add("Date", System.Type.GetType("System.String"))
dTable.Columns.Add("Start", System.Type.GetType("System.String"))
dTable.Columns.Add("End", System.Type.GetType("System.String"))
dTable.Columns.Add("NumAttendees", System.Type.GetType("System.String"))
dTable.Columns.Add("Type", System.Type.GetType("System.String"))
dTable.Columns.Add("Setup", System.Type.GetType("System.String"))
dTable.Columns.Add("AV", System.Type.GetType("System.String"))
dTable.Columns.Add("NumDays", System.Type.GetType("System.String"))
ds.Tables.Add(dTable)
End If
Dim dr As DataRow = dTable.NewRow()
dr(0) = "test"
dr(1) = "test"
dr(2) = "test"
dr(3) = "test"
dr(4) = "test"
dr(5) = "test"
dr(6) = "test"
dr(7) = "test"
dTable.Rows.Add(dr)
MeetingDetails.DataSource = ds
MeetingDetails.DataBind()
Can someone shed some light?
Thanks,
Marc