CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums

ASP.NET Web Hosting – 3 Months Free!



Zone: > NEWSGROUP > Asp.Net Forum > visual_studio.visual_studio_2005 Tags:
Item Type: NewsGroup Date Entered: 12/7/2007 3:44:47 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 2 Views: 31 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
3 Items, 1 Pages 1 |< << Go >> >|
mominlhp
Asp.Net User
Dropdownlist and first index12/7/2007 3:44:47 PM

0/0

 

 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
ecbruck
Asp.Net User
Re: Dropdownlist and first index12/7/2007 4:35:02 PM

0/0

Don't do that. Instead, just defin your ListItem declaratively within your control and set the AppendDataBoundItems property to True. 

<asp:dropdownlist id="ddlmobProvider" runat="server" appenddatabounditems="true"
	datasourceid="mobileProvider" datatextfield="ProviderName" datavaluefield="MobilePhoneProviderID"
	width="250px">
	<asp:listitem text="Please select a Provider" value="-1" />
</asp:dropdownlist>

Thanks, Ed

Microsoft MVP - ASP/ASP.NET

Please remember to 'Mark as Answer' if this post answered your question!
mominlhp
Asp.Net User
Re: Dropdownlist and first index12/7/2007 5:01:43 PM

0/0

 Wonderful. Thanks a lot. Its working....Big Smile


Thanks
~AK
3 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Microsoft Office Access 2003 Inside Out Authors: John Viescas, Pages: 1298, Published: 2003
A Practical Guide to Localization Authors: Bert Esselink, Pages: 490, Published: 2000
Pro Access 2007 Authors: Martin W. P. Reid, Pages: 395, Published: 2007
Beginning ASP.NET 2.0 Databases: Beta Preview Authors: John Kauffman, Thiru Thangarathinam, Pages: 427, Published: 2005
Programming Data-driven Web Applications with ASP.NET Authors: Don Wolthuis, Donny Mack, Doug Seven, Pages: 704, Published: 2002
Mastering Microsoft Windows Vista Home: Premium and Basic Authors: Guy Hart-Davis, Pages: 1042, Published: 2007
Professional C# Authors: Simon Robinson, Christian Nagel, Karli Watson, Jay Glynn, Morgan Skinner, Bill Evjen, Pages: 1224, Published: 2004
e-quals level 2 databases for office xp: Level 2 Diploma for IT Users for City & Guilds Authors: Sue Ward, Pages: 140, Published: 2004
ASP.NET 2.0 MVP Hacks and Tips Authors: David Yack, Joe Mayo, Scott Hanselman, Fredrik Normén, Dan Wahlin, J. Ambrose Little, Jonathan Goodyear, Pages: 400, Published: 2006

Web:
Adobe Forums - Populate Text Field Based On Drop-Down List Selection When I click another selection from the drop down list the first entry ... http: //www.adobe.com/cfusion/search/index.cfm?loc=en_us&term=livecycle+javascript ...
Order of drop down list - Big Red Spark Forums I thought that the list would stay the same and that I would not need to add any more courses (I had input the first list of courses in ...
Maintaining DropDownList selected index Talk about Maintaining DropDownList selected index. ... The first index is a text field describing all items. ...
drop down list, selected index changed - same values different ... drop down list, selected index changed - same values different text .... but... the value appeared is still the first index. ...
Asp.net Dropdownlist selected index in changed Sep 4, 2006 ... selection index of first two dropdownlist is not changed but the third selected index of third dropdownlist is changed ...
First Index If the correct material is not on the dropdown list, select Other. Enter any additional information ... Don't have FirstIndex™ ID? Registration is FREE! ...
Display data in dropdownlist using LINQ - MSDN Forums Mar 28, 2008 ... I just want to append the first index value of dropdownlist as - -Select customer name - - like this . how can i do? ...
dropdownlist databinding 8)dropdownlist first index is "Select" Dim strConn As String strConn = "USER= tttt;PASSWORD=cccc;SERVER=gggg;DATABASE=Emp" ...
p2p.wrox.com Forums - DropDownList selectedindex retrieval I have a DropDownList which gets populated on Edit event of the DataGrid. But on Update event the selected index always gives the first ...
Dropdownlist index change event problem. Nov 10, 2007 ... Report as spam Question - Post 1 of 1; Dropdownlist index change event ... first I select Mangemment type of employee grid view showing that ...

Videos:
Long Beach City Council Meeting Long Beach City Council Meeting




Search This Site:










error when creating a new web site in visual studio 2005

the best code documentation generator for .vs 2005?

code change impact analysis

app_code folder bug

smarttags

url path

ajax question

change the language in web.config

website admin tool with long folder names

publishing to remote or local server has stopped working v2.0

"unable to find connection" error

visual studio 2005 remote debugging in windows 2003 server sp1 please help!

collapsable text background color

settings do not get restored as they should be!

how do i get the configuration manager to use a domain

vs 2005 and vss 6.0

vista + vs2005 = no drag&drop + no doubleclick

property sheet not holding values

visual basic 20005 - connect access database

delete of codefile, re-adding codefile - 'context is not a member of xxx.'

referenced assembly

debug breakpoints not hit

how do you remove project templates from vs 2005?

clr20r3 event and the parameter descriptions

vs 2005 pro** file>>new>>web site ** no templates!!!

permissions issue

smart tags won't open and some intellisense won't fully work after installing linq ctp

try catch error best practices

anonymous method code reformatting! (c#)

how to set autopost property of treeview control to false

  Privacy | Contact Us
All Times Are GMT