Can you show me an example of Grid with dropdownlist for a column using a datatable as source using vb.net?
<ej:Grid ID="DetailGrid" runat='server'>
<EditSettings AllowEditing="true" AllowAdding="true" AllowEditOnDblClick="true" RowPosition="Top"EditMode="InlineForm" />
<ClientSideEvents ActionComplete="complete" />
<Columns>
<ej:Column Field="OrderID" HeaderText="ID" IsPrimaryKey="true" Visible="false"></ej:Column>
<ej:Column Field="EmployeeID" HeaderText="Time" Width="70" AllowEditing="true" EditType="DropdownEdit"></ej:Column>
. . .
</Columns>
</ej:Grid>
</ContentTemplate>
</asp:UpdatePanel>
Serverside:-
Public data As IEnumerable
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
Dim myConnection As SqlConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("NORTHWNDConnectionString").ToString())
Dim dt As DataTable = New DataTable("Orders")
Dim cmd As SqlCommand = New SqlCommand()
cmd.Connection = myConnection
cmd.CommandText = "select * from Employees"
cmd.CommandType = CommandType.Text
Dim da As SqlDataAdapter = New SqlDataAdapter()
da.SelectCommand = cmd
If myConnection.State = ConnectionState.Closed Then
myConnection.Open()
End If
da.Fill(dt)
Dim dropObj As List(Of Object) = New List(Of Object)()
Using dr As SqlDataReader = cmd.ExecuteReader()
While dr.Read()
dropObj.Add(New With {Key
.text = dr.GetValue(0).ToString(), Key
.value = dr.GetValue(0)
})
End While
End Using
Me.DetailGrid.Columns(1).DataSource = dropObj //Bind Dropdownlist for Column
Session("SqlDataSource") = dt
BindDataSource()
End Sub |
Default.aspx:-
<ej:Grid ID="Grid1" runat="server" AllowPaging="True" ClientIDMode="Static" IsResponsive="true" EnableResponsiveRow="true">
<ClientSideEvents RowSelecting="rowSelecting" />
. . .
</ej:Grid> |
ClientIDMode="Static" worked thanks for the help