queenannsrev
Member
- Joined
- Jun 28, 2005
- Messages
- 6
- Programming Experience
- Beginner
Resolved
This is a web application
The issue is I can bind the data grid when I allow the auto colum generate but when I try to add columns myself I can't get the data to show in the grid. I am passing values in an array. Below is my code for passing two parameters to a stored procedure and filling my grid. Works great until I add my own columns to the data grid.
'****************************************************************************************
Passes data to array
'****************************************************************************************
Cnsql.Open()
strSpName = "spSelectRailWorkSheetData"
Dim strGridN As DataGrid
strGridN = dgFuelRailWSheet
Dim TName AsString
TName = "tblRaIndvPartInfo"
'Fills Data Grid
'Cnsql.Open()
Dim RaPartInfo(2) As SqlParameter
RaPartInfo(0) = New SqlParameter("@RaNumber", SqlDbType.Int)
RaPartInfo(0).Value = RaNumber
RaPartInfo(1) = New SqlParameter("@DashNumber", SqlDbType.Int)
RaPartInfo(1).Value = ddlSelectDash.SelectedValue
FillDataGridArray(strSpName, strGridN, TName, RaPartInfo)
Cnsql.Close()
'************************************************
This is FillDataGridArray
'************************************************
PublicFunction FillDataGridArray(ByVal strSpName AsString, ByVal dgDataGrid As DataGrid, ByVal tblName AsString, ByValParamArray parm() As SqlParameter)
Dim cnSQL AsNew SqlConnection(ConfigurationSettings.AppSettings("ConnectionStringRA"))
Dim daSql As SqlDataAdapter = New SqlDataAdapter
Dim cmSql As SqlCommand = New SqlCommand(strSpName, cnSQL)
cmSql.CommandType = CommandType.StoredProcedure
If (cmSql IsNothing) ThenThrowNew ArgumentNullException("strSpName")
If (Not parm IsNothing) Then
Dim P As SqlParameter
ForEach P In parm
If (P IsNothing) Then
Else
cmSql.Parameters.Add(P)
EndIf
Next P
EndIf
Dim ds As DataSet = New DataSet
Try
daSql.SelectCommand = cmSql
daSql.Fill(ds, tblName)
dgDataGrid.DataSource = ds
dgDataGrid.DataBind()
daSql.Dispose()
cnSQL.Close()
Catch ex As Exception
EndTry
EndFunction
As I said works great when I do auto generate colums but when I use the Property builder and add my own colums to add txt boxes or ddl It won't work.
Resolved
This is a web application
The issue is I can bind the data grid when I allow the auto colum generate but when I try to add columns myself I can't get the data to show in the grid. I am passing values in an array. Below is my code for passing two parameters to a stored procedure and filling my grid. Works great until I add my own columns to the data grid.
'****************************************************************************************
Passes data to array
'****************************************************************************************
Cnsql.Open()
strSpName = "spSelectRailWorkSheetData"
Dim strGridN As DataGrid
strGridN = dgFuelRailWSheet
Dim TName AsString
TName = "tblRaIndvPartInfo"
'Fills Data Grid
'Cnsql.Open()
Dim RaPartInfo(2) As SqlParameter
RaPartInfo(0) = New SqlParameter("@RaNumber", SqlDbType.Int)
RaPartInfo(0).Value = RaNumber
RaPartInfo(1) = New SqlParameter("@DashNumber", SqlDbType.Int)
RaPartInfo(1).Value = ddlSelectDash.SelectedValue
FillDataGridArray(strSpName, strGridN, TName, RaPartInfo)
Cnsql.Close()
'************************************************
This is FillDataGridArray
'************************************************
PublicFunction FillDataGridArray(ByVal strSpName AsString, ByVal dgDataGrid As DataGrid, ByVal tblName AsString, ByValParamArray parm() As SqlParameter)
Dim cnSQL AsNew SqlConnection(ConfigurationSettings.AppSettings("ConnectionStringRA"))
Dim daSql As SqlDataAdapter = New SqlDataAdapter
Dim cmSql As SqlCommand = New SqlCommand(strSpName, cnSQL)
cmSql.CommandType = CommandType.StoredProcedure
If (cmSql IsNothing) ThenThrowNew ArgumentNullException("strSpName")
If (Not parm IsNothing) Then
Dim P As SqlParameter
ForEach P In parm
If (P IsNothing) Then
Else
cmSql.Parameters.Add(P)
EndIf
Next P
EndIf
Dim ds As DataSet = New DataSet
Try
daSql.SelectCommand = cmSql
daSql.Fill(ds, tblName)
dgDataGrid.DataSource = ds
dgDataGrid.DataBind()
daSql.Dispose()
cnSQL.Close()
Catch ex As Exception
EndTry
EndFunction
As I said works great when I do auto generate colums but when I use the Property builder and add my own colums to add txt boxes or ddl It won't work.
Resolved
Last edited: