0
我想在telerik gridview中嵌入一個組合框,但它甚至沒有在網格中加載。wintid在telerik radgridview中的組合框
我想通過使用存儲過程從數據庫中的表中獲取值。
我的代碼版本如下:
Private Sub GetDocType()
Try
Dim db As New gpcdb.dbaccess
Dim cmd As New SqlClient.SqlCommand
cmd = db.GetSqlDBCmd("gpc_DocumentType", CommandType.StoredProcedure)
Dim ddlDocType As DataGridViewComboBoxColumn = New DataGridViewComboBoxColumn
cmd.Connection.Open()
ddlDocType.ValueMember = "gpcDocTypeID"
ddlDocType.DisplayMember = "docType"
ddlDocType.DataSource = cmd.ExecuteReader
cmd.Connection.Close()
'grdDragDoc.Rows(9)
db = Nothing
cmd = Nothing
Catch ex As Exception
MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Private Sub grdDragDoc_CellEditorInitialized(sender As Object, e As Telerik.WinControls.UI.GridViewCellEventArgs) Handles grdDragDoc.CellEditorInitialized
Dim db As New gpcdb.dbaccess
Dim cmd As New SqlClient.SqlCommand
cmd = db.GetSqlDBCmd("gpc_DocumentType", CommandType.StoredProcedure)
Dim ddlDocType As DataGridViewComboBoxColumn = New DataGridViewComboBoxColumn
cmd.Connection.Open()
ddlDocType.ValueMember = "gpcDocTypeID"
ddlDocType.DisplayMember = "docType"
ddlDocType.DataSource = cmd.ExecuteReader
cmd.Connection.Close()
If e.Column.Name = "ddlDocType" Then
Dim editor As RadDropDownListEditor = TryCast(Me.grdDragDoc.ActiveEditor, RadDropDownListEditor)
If Not editor Is Nothing Then
CType((CType(Me.grdDragDoc.ActiveEditor, RadDropDownListEditor)).EditorElement, RadDropDownListEditorElement).RightToLeft = True
End If
End If
'grdDragDoc.Columns.Add(ddlDocType)
'grdDragDoc.Rows(9)
db = Nothing
cmd = Nothing
End Sub
Private Sub grdDragDoc_CellValueChanged(sender As Object, e As Telerik.WinControls.UI.GridViewCellEventArgs) Handles grdDragDoc.CellValueChanged
Try
Dim ddlDocType As DataGridViewComboBoxColumn = New DataGridViewComboBoxColumn
'If e.ColumnIndex = ddlDocType.Index Then
Dim retreivedValue As Object = grdDragDoc.Rows(grdDragDoc.CurrentRow.Index).Cells(9)
Catch ex As Exception
End Try
End Sub
Private Sub DocumentListLoad()
Try
Dim objDoc As New gpcdb.document
Dim cmd As New SqlClient.SqlCommand
cmd = objDoc.DocumentList(_ClientID)
cmd.Connection.Open()
grdDragDoc.LoadFrom(cmd.ExecuteReader(CommandBehavior.CloseConnection))
'lstDocuments.DataSource = cmd.ExecuteReader(CommandBehavior.CloseConnection)
'Assign drop down list to column in the grid
Dim ddlDocType As DataGridViewComboBoxColumn = New DataGridViewComboBoxColumn
cmd.Connection.Close()
cmd = Nothing
objDoc = Nothing
Catch ex As Exception
MessageBox.Show(ex.Message, "DocumentListLoad", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub