Try to use this code i am sure it will work for you.
HTML Code:
<%@ Page Language=”C#” %>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<script runat=”server”>
protected void DropDownListUser_DataBound(object sender, EventArgs e)
{
DropDownListUser.SelectedIndex =
DropDownListUser.Items.IndexOf
(DropDownListUser.Items.FindByValue(Context.User.Identity.Name));
}
</script>
<html xmlns=”http://www.w3.org/1999/xhtml” >
<head runat=”server”>
<title>DropDownList Initialize</title>
</head>
<body>
<form id=”form1″ runat=”server”>
<div>
<asp:DropDownList ID=”DropDownListUser” runat=”server”
DataSourceID=”ObjectDataSourceUser”
DataTextField=”UserName” DataValueField=”UserName”
OnDataBound=”DropDownListUser_DataBound”>
</asp:DropDownList>
<asp:ObjectDataSource ID=”ObjectDataSourceUser” runat=”server”
SelectMethod=”GetMembers”
TypeName=”MembershipUtilities.MembershipUserODS”>
<SelectParameters>
<asp:Parameter Name=”sortData” Type=”String” />
</SelectParameters>
</asp:ObjectDataSource>
</div>
</form>
</body>
</html>
Bookmarks