The popup edit window will not load when I have this line of code: "SelectedValue='<%# Bind("LocationID") %>". My suspicion is because the DropDownList is populating after the control attempts to bind the SelectedValue, but I'm not sure. I have verified that the SelectedValue I am binding is in fact a value that is in the DropDownList.
Form Template:
<tr>
<td>Location:</td>
<td>
<asp:DropDownList ID="ddlDevicesLocation" runat="server" SelectedValue='<%# Bind("LocationID") %>'>
</asp:DropDownList>
</td>
</tr>
C# Populate DropDown :: (OnItemDataBound)
protected void DevicesGrid_PopulateFields(object sender, GridItemEventArgs e)
{
if ((e.Item is GridEditFormItem) && (e.Item.IsInEditMode))
{
GridEditFormItem editform = (GridEditFormItem)e.Item;
// Define fields that we need to work with
DropDownList locationddl = (DropDownList)editform.FindControl("ddlDevicesLocation");
DropDownList typeddl = (DropDownList)editform.FindControl("typeddl");
TextBox PrinterIP = (TextBox)editform.FindControl("PrinterIP");
TextBox PrinterName = (TextBox)editform.FindControl("PrinterName");
TextBox PrinterPort = (TextBox)editform.FindControl("PrinterPort");
// Fill Location DropDown
LocationDropDown(locationddl);
}
}
Form Template:
<tr>
<td>Location:</td>
<td>
<asp:DropDownList ID="ddlDevicesLocation" runat="server" SelectedValue='<%# Bind("LocationID") %>'>
</asp:DropDownList>
</td>
</tr>
C# Populate DropDown :: (OnItemDataBound)
protected void DevicesGrid_PopulateFields(object sender, GridItemEventArgs e)
{
if ((e.Item is GridEditFormItem) && (e.Item.IsInEditMode))
{
GridEditFormItem editform = (GridEditFormItem)e.Item;
// Define fields that we need to work with
DropDownList locationddl = (DropDownList)editform.FindControl("ddlDevicesLocation");
DropDownList typeddl = (DropDownList)editform.FindControl("typeddl");
TextBox PrinterIP = (TextBox)editform.FindControl("PrinterIP");
TextBox PrinterName = (TextBox)editform.FindControl("PrinterName");
TextBox PrinterPort = (TextBox)editform.FindControl("PrinterPort");
// Fill Location DropDown
LocationDropDown(locationddl);
}
}