I have a FormTemplate
I tried to fill data for the DropDownList in ItemDataBound event but the DropDownList is empty even Role.GetAll() returns 3 items.
Also I tried to apply as this example: http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/templateformupdate/defaultcs.aspx, but in Visual Studio,
| <FormTemplate> |
| <table> |
| <tr> |
| <td> |
| First name: |
| </td> |
| <td> |
| <asp:TextBox ID="txtFirstName" runat="server" Text='<%# Bind("FirstName") %>'></asp:TextBox> |
| </td> |
| <td> |
| Last name: |
| </td> |
| <td> |
| <asp:TextBox ID="txtLastName" runat="server" Text='<%# Bind("LastName") %>'></asp:TextBox> |
| </td> |
| <td> |
| Role: |
| </td> |
| <td> |
| <asp:DropDownList ID="ddlRoles" runat="server"></asp:DropDownList> |
| </td> |
| <td align="right"> |
| <asp:LinkButton ID="btnUpdate" runat="server" CommandName="Update" Visible='<%# Eval("Id").ToString().Length != 0 %>'>Update</asp:LinkButton> |
| <asp:LinkButton ID="btnAdd" runat="server" CommandName="PerformInsert" Visible='<%# Eval("Id").ToString().Length == 0 %>'>Add</asp:LinkButton> |
| |
| <asp:LinkButton ID="btnCancel" runat="server" CommandName="Cancel">Cancel</asp:LinkButton> |
| </td> |
| </tr> |
| </table> |
| </FormTemplate> |
| protected void rgUsers_ItemCommand(object source, GridCommandEventArgs e) |
| { |
| if ((e.Item is GridEditFormItem) && (e.Item.IsInEditMode)) |
| { |
| GridEditFormItem editedItem = (GridEditFormItem) e.Item; |
| DropDownList ddlRoles = (DropDownList)editedItem.FindControl("ddlRoles"); |
| ddlRoles.DataSource = Role.GetAll(); |
| ddlRoles.DataTextField = "Name"; |
| ddlRoles.DataValueField = "Id"; |
| } |
| } |
I tried to fill data for the DropDownList in ItemDataBound event but the DropDownList is empty even Role.GetAll() returns 3 items.
Also I tried to apply as this example: http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/templateformupdate/defaultcs.aspx, but in Visual Studio,
SelectedValue of DropDownList doesn't show up.