DropDownList Default Value Not Selected in Edit Mode when using IE.

6 replies. Last post: February 17, 2010 11:13 PM by Glenn Layaar
Tags :
  • (None)
  • New Discussion
  • New Question
  • New Product Feedback

The DropDownList Default Value is Not Selected in Edit Mode when using IE.

With the code below:

  • - Display the page in IE 8
  • - Double Click the WebGrid Row 1, Column 1, Priority to change to Edit Mode
  • - A DropDown List is displayed however UNDECIDED is not selected
    • With other Browsers such as Mozilla it is selected
    • The stand alone DropDown List above the WebGrid has it selected
<%@ Page Language="C#" AutoEventWireup="true" %>

<%@ Import Namespace="System.Data" %>


<%@ Register assembly="ISNet.WebUI.WebGrid" namespace="ISNet.WebUI.WebGrid" tagprefix="ISWebGrid" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">
    <title></title>
    
	<script runat="server">
		
		protected void _WebGrid_InitializeLayout(object sender, LayoutEventArgs e)
		{
			ISNet.WebUI.WebGrid.WebValueList Priority_WebValueList = _WebGrid.GetTableByName("").Columns.GetNamedItem("Priority_WebGridColumn").ValueList;

			SortedList Priority_SortedList = new SortedList();

			Priority_SortedList.Add("ASSESS - 1", "1");
			Priority_SortedList.Add("ASSESS - 2", "2");
			Priority_SortedList.Add("ASSESS - 3", "3");
			Priority_SortedList.Add("DISPOSE", "D");
			Priority_SortedList.Add("UNDECIDED", "");

			Priority_WebValueList.DataSource = Priority_SortedList;
			Priority_WebValueList.DataTextField = "Key";
			Priority_WebValueList.DataValueField = "Value";

			RefurbPriority_DropDownList.DataSource = Priority_SortedList;
			RefurbPriority_DropDownList.DataTextField = "Key";
			RefurbPriority_DropDownList.DataValueField = "Value";

			RefurbPriority_DropDownList.SelectedValue = "";

			RefurbPriority_DropDownList.DataBind();
		}


		protected void Company_DropDownList_PreRender(object sender, EventArgs e)
		{
			DropDownList _DropDownList = (DropDownList) sender;
			_DropDownList.Items.Insert(0, "--- PLEASE SELECT ---");
		}
				
	</script>

</head>

<body>
    <form id="form1" runat="server">
    <div>

	<table>
		<tr>
			<td>PRIORITY</td>
			<td>COMPANY</td>
		</tr>
		<tr>
			<td>
				<ASP:DROPDOWNLIST 
					ID="RefurbPriority_DropDownList" 
					runat="server"
				>
				</ASP:DROPDOWNLIST>
			</td>
			<td>
				<ASP:DROPDOWNLIST 
					ID="Company_DropDownList" 
					runat="server" 
					DataValueField="CustomerID"
					DataTextField="CompanyName"
					DataSourceID="Company_SqlDataSource"
					onPreRender="Company_DropDownList_PreRender"
				>
				</ASP:DROPDOWNLIST>
				
			</td>
		</tr>
		<tr>
			<td colspan="2">
				<ISWebGrid:WebGrid 
					ID="_WebGrid"
					runat="server"
					DataSourceID="Orders_SqlDataSource"
					Height="250px"
					UseDefaultStyle="True"
					DefaultStyleMode="Win7"
					OnInitializeLayout="_WebGrid_InitializeLayout"
				>
					<LayoutSettings
						AllowEdit="Yes"
						AllowSorting="Yes"
						AllowBatchUpdate="true"
					>
						<BatchUpdateSettings
							AllowReviewChanges="true"
							AutomaticObjectUpdate="false"
						/>
					</LayoutSettings>
					<RootTable
						DataKeyField="OrderID"
					>
						<Columns>
							<ISWebGrid:WebGridColumn
								Name="Priority_WebGridColumn"
								Bound="True"
								DataMember="REFURB_PRIORITY"
								EditType="DropdownList"
								Caption="PRIORITY"
								Width="100px"
								NullText=""
								DefaultValue=""
								InputRequired="true"
								InputRequiredErrorText="Priority Needed"
							>
							</ISWebGrid:WebGridColumn>
							<ISWebGrid:WebGridColumn
								Name="Company_WebGridColumn"
								Bound="True"
								EditType="DropdownList"
								Caption="Company"
								Width="100px"
								InputRequired="false"
							>
								<ValueList
									DataSourceID="Company_SqlDataSource"
									DataTextField="CompanyName"
									DataValueField="CustomerID"
								>
								</ValueList>
								<CellStyle BackColor="Yellow"/>
							</ISWebGrid:WebGridColumn>
							<ISWebGrid:WebGridColumn
								Caption="Order ID"
								EditType="NoEdit"
								DataMember="OrderID"
								Name="OrderID_WebGridColumn"
								Width="100px"
							>
								<CellStyle ForeColor="Black"/>
							</ISWebGrid:WebGridColumn>

						</Columns>
					</RootTable>
				</ISWebGrid:WebGrid>
				</td>
		</tr>
	</table>
	
	<asp:SqlDataSource
		ID="Company_SqlDataSource"
		runat="server"
		ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString2005 %>"
		SelectCommand="SELECT [CustomerID], [CompanyName] FROM [Customers] ORDER BY [CustomerID]"
	></asp:SqlDataSource>

	<asp:SqlDataSource
		ID="Orders_SqlDataSource"
		runat="server"
		ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString2005 %>"
		SelectCommand="SELECT TOP 5 [OrderID], [CustomerID], '' AS REFURB_PRIORITY, '' AS GRAPHICS_NEW FROM [Orders] ORDER BY [OrderID]"
	></asp:SqlDataSource>

    </div>
    </form>
</body>
</html>

 

 

All times are GMT -5. The time now is 7:27 AM.
Previous Next