Hi
I load the grid and GridDropDownColumn column from code behind, everty thing works fine except the first row doesn't show the value
thanks
small sample which I found from Forum
code behind
I load the grid and GridDropDownColumn column from code behind, everty thing works fine except the first row doesn't show the value
thanks
small sample which I found from Forum
<div> <telerik:RadGrid runat="server" ID="RadGrid1" AutoGenerateColumns="false" AllowPaging="true" AutoGenerateEditColumn="true" > <MasterTableView EditMode="InPlace"> <Columns> <telerik:GridBoundColumn DataField="Col1"> </telerik:GridBoundColumn> <telerik:GridDropDownColumn DataField="Col2" ListTextField="value" ListValueField="index" UniqueName="DropDownColumn"> </telerik:GridDropDownColumn> </Columns> </MasterTableView> </telerik:RadGrid> </div>code behind
Imports Telerik.Web.UIPublic Class WebForm6 Inherits System.Web.UI.Page Private _isBound As Boolean = False Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load End Sub Private Sub RadGrid1_ItemCreated(sender As Object, e As Telerik.Web.UI.GridItemEventArgs) Handles RadGrid1.ItemCreated If TypeOf e.Item Is GridDataItem Then If Not _isBound Then DirectCast(DirectCast(RadGrid1.MasterTableView.GetColumnSafe("DropDownColumn"), GridDropDownColumn).ColumnEditor, GridDropDownColumnEditor).DataSource = GetDropDownData() _isBound = True End If End If End Sub Private Sub RadGrid1_NeedDataSource(sender As Object, e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource RadGrid1.DataSource = GetGridData() End Sub Private Function GetDropDownData() As DataTable Dim dataTable As New DataTable() dataTable.Columns.Add("index") dataTable.Columns.Add("value") For i As Integer = 0 To 19 dataTable.Rows.Add(New Object() {i, i}) Next Return dataTable End Function Private Function GetGridData() As DataTable Dim dataTable As New DataTable() dataTable.Columns.Add("Col1") dataTable.Columns.Add("Col2") For i As Integer = 0 To 19 dataTable.Rows.Add(New Object() {i, i}) Next Return dataTable End FunctionEnd Class