rokitsalad
Programmer
I have a sql server stored procedure from which I'm creating a dataset containing rows which I want to display in a datagrid on my web page. The dataset is populated depending on the value in a text box on my page (all pretty basic stuff so far).
My problem is that I can't work out how to control which columns appear in my datagrid. I can't use the vs gui because the dataset is not created until the onclick event of my search button. Here's som of my code:
Dim con As New SqlConnection(ConfigurationSettings.AppSettings("SiteAccidentsCon"))
Dim adapter As New SqlDataAdapter("exec siteaccidents_getmonthend '" & tbContractNumber.Text & "'", con)
Dim ds As New DataSet
Dim dv As New DataView
con.Open()
Try
adapter.Fill(ds)
con.Close()
con.Dispose()
dgAccidents.DataSource = ds
dgAccidents.DataKeyField = "ref"
dgAccidents.DataBind()
dgAccidents.Visible = True
ds.Clear()
ds.Dispose()
Catch ex As Exception
What I want to do is prevent the keyfield from appearing in the datagrid and add a template column with a text box in it which will accept integer input. I can pretty much work things out once I know how to control which columns appear. At the moment, all columns from the dataset are listed.
Any help is greatly appreciated.
Pete.
My problem is that I can't work out how to control which columns appear in my datagrid. I can't use the vs gui because the dataset is not created until the onclick event of my search button. Here's som of my code:
Dim con As New SqlConnection(ConfigurationSettings.AppSettings("SiteAccidentsCon"))
Dim adapter As New SqlDataAdapter("exec siteaccidents_getmonthend '" & tbContractNumber.Text & "'", con)
Dim ds As New DataSet
Dim dv As New DataView
con.Open()
Try
adapter.Fill(ds)
con.Close()
con.Dispose()
dgAccidents.DataSource = ds
dgAccidents.DataKeyField = "ref"
dgAccidents.DataBind()
dgAccidents.Visible = True
ds.Clear()
ds.Dispose()
Catch ex As Exception
What I want to do is prevent the keyfield from appearing in the datagrid and add a template column with a text box in it which will accept integer input. I can pretty much work things out once I know how to control which columns appear. At the moment, all columns from the dataset are listed.
Any help is greatly appreciated.
Pete.