I have done this repeadedly in other grid but for some reason when I transformed to C# nothing seems to work for me when I try to translate VB ways to C# ways, The code is differenet but the functionality of grid stays the same. I am trying to populate the Dropwdown list from a database which is successful, however i want to assign and id from the database to the drowpdownlist and its not working it will not assign at all. Works fine in Vb, but C# no go.
<EditFormSettings EditFormType="Template"> <FormTemplate> <table style="width:100%;background-color:antiquewhite"> <tr> <td style="height:10px"></td> </tr> <tr> <td style="width:10%;text-align:right">Name: </td> <td style="width:90%;text-align:left"><asp:Label ID="lblName" runat="server" Text='<%#Bind("TokenFor") %>'></asp:Label></td> </tr> <tr> <td style="height:3px"></td> </tr> <tr> <td style="width:10%;text-align:right">Persona: </td> <td style="width:90%;text-align:left"><asp:DropDownList ID="ddlPersona" runat="server"></asp:DropDownList></td> </tr> <tr> <td style="height:3px"></td> </tr> <tr> <td style="width:10%;text-align:right">Email: </td> <td style="width:90%;text-align:left"><asp:TextBox ID="txtEmail" runat="server" Text='<%#Bind("strTokenEmail") %>' Width="260px"></asp:TextBox></td> </tr> <tr> <td style="height:3px"></td> </tr> <tr> <td style="width:10%;text-align:right">Phone: </td> <td style="width:90%;text-align:left"><asp:TextBox ID="txtPhone" runat="server" Text='<%#Bind("strPhoneNum") %>'></asp:TextBox></td> </tr> <tr> <td style="height:20px"></td> </tr> <tr> <td style="height:3px"></td> </tr> <tr> <td style="width:10%;text-align:right">Location: </td> <td style="width:90%;text-align:left"><asp:DropDownList ID="ddlLocation" runat="server"></asp:DropDownList></td> </tr> <tr> <td style="height:3px"></td> </tr> <tr> <td style="width:10%;text-align:right"></td> <td style="width:90%;text-align:left"> <asp:LinkButton ID="lnkSubmit" runat="server" Text='<%# ((bool)DataBinder.Eval(Container, "OwnerTableView.IsItemInserted")) ? "Insert" : "Update" %>' CommandName='<%# ((bool)DataBinder.Eval(Container, "OwnerTableView.IsItemInserted")) ? "PerformInsert" : "Update" %>'> </asp:LinkButton> <asp:LinkButton ID="lnkCancel" runat="server" CausesValidation="false" CommandName="Cancel" Text="Cancel"></asp:LinkButton> </td> </tr> <tr> <td style="height:10px"></td> </tr> </table> </FormTemplate> </EditFormSettings> protected void myRadGrid_ItemDataBound(object sender, GridItemEventArgs e) { if ((e.Item is GridEditFormItem) && (e.Item.IsInEditMode)) { GridEditFormItem item = (GridEditFormItem)e.Item; DropDownList ddlLocation = (DropDownList)item.FindControl("ddlLocation"); DropDownList ddlPersona = (DropDownList)item.FindControl("ddlPersona"); sql = "Select intPersonaId, strPersonaLtr + ' - ' + strPersona Persona from tblPersona where bitActive = 1"; ddlPersona.DataSource = c.GetReader(sql); ddlPersona.DataTextField = "Persona"; ddlPersona.DataValueField = "intPersonaId"; ddlPersona.DataBind(); ddlPersona.SelectedValue = (string)DataBinder.Eval(e.Item.DataItem, "intPersonaId").ToString(); sql = "Select intLocationId, strLocation from tblLocations where bitActive = 1"; ddlLocation.DataSource = c.GetReader(sql); ddlLocation.DataTextField = "strLocation"; ddlLocation.DataValueField = "intLocationId"; ddlLocation.Items.Add(new ListItem("Pick Location", "0")); ddlLocation.DataBind(); ddlLocation.SelectedValue = (string)DataBinder.Eval(e.Item.DataItem, "intLocationTokenId").ToString(); }