In a formview I have few textbox, label, and two dropdownlist. On
one of the dropdownlist, its calling a method to display data from the
database. Its working fine. But I am trying to add a text in the
dropdownlist like " Please select a value". I tried a databinding. But got the following error.
Compiler Error Message: CS0103: The name 'ddlmobProvider' does not exist in the current context.
Can anybody help me with this please?
aspx file:
<asp:FormView ID="FormView1" runat="server" DataSourceID="odsProfile" DefaultMode="Edit" CellPadding="2" ForeColor="White" Width="84%" BorderStyle="None" CellSpacing="2" >
<EditItemTemplate>
<table style="width: 100%" onmouseover="RegisterHighlighterEvents(this, false, false);" >
<tr ><td ><b>User Name:</b></td><td ><asp:TextBox ID="UserName" Text='<%# Bind("UserName") %>' ReadOnly="true" runat="server" width="250px"/></td></tr>
<tr><td ><b>First Name:</b></td><td ><asp:TextBox runat="server" ID="FirstName" Text='<%# Bind("FirstName") %>' Width="250px"/></td></tr>
<tr><td ><b>Last Name:</b></td><td ><asp:TextBox runat="server" ID="LastName" Text='<%# Bind("LastName") %>' Width="250px"/></td></tr>
<tr><td ><b>Company:</b></td><td><asp:TextBox runat="server" ID="TextCompany" Value='<%# Eval("Company") %>' ReadOnly="true" /></td></tr>
<asp:HiddenField ID="Company" runat="server" Value='<%# Bind("CompanyID") %>' />
<tr><td ><b>E-mail:</b></td><td ><asp:TextBox runat="server" ID="Make" Text='<%# Bind("Email") %>' Width="250px"/></td></tr>
<tr><td><b>Time Zone: </b></td><td><asp:DropDownList ID="ddltimezone" OnLoad="ddltimezone_OnLoad"
DataSourceID="timezone" DataValueField="TimeZoneID" DataTextField="TimeName" runat="server"
Width="250px" SelectedValue='<%# Bind("TimeZoneID") %>' ></asp:DropDownList><br />
<tr><td ><b>Mobile Number:</b></td><td ><asp:TextBox runat="server" ID="TextBox1" Text="" Width="250px"/></td></tr>
<tr><td ><b>Mobile Provider:</b></td><td><asp:DropDownList ID="ddlmobProvider" OnDataBinding="ddlmobProvider_DataBinding"
DataSourceID="mobileProvider" DataValueField="MobilePhoneProviderID" DataTextField="ProviderName" runat="server"
Width="250px" ></asp:DropDownList><br />
<asp:ObjectDataSource ID="timezone" runat="server" SelectMethod="GetTimeZoneList" TypeName="CommonDB"></asp:ObjectDataSource>
<asp:ObjectDataSource ID="mobileProvider" runat="server" SelectMethod="GetMobileProviderList" TypeName="CommonDB" ></asp:ObjectDataSource>
<br />
Behind the code:
protected void ddlmobProvider_DataBinding(object sender, EventArgs e)
{
ddlmobProvider.Items.Add(new DataList("Please select a Provider", "-1"));
}
Thanks
~AK