AppendDataBoundItems="true" doesn't work for 2nd drop down box that is "filtered" based on selection of first drop down box.

I have two drop down boxes.  Department, and Employees.  In my vb.net form, when a user selects Department, the Employees dropdown binds, but instead of listing the first name, I want to list "Please make a selection"... I've tried the appenddatabounditems (see below), but it doesn't seem to work.  What am I missing??

<asp:SqlDataSource ID="getDept" runat="server" ConnectionString="<%$ ConnectionStrings:xxxConnectionString %>"
SelectCommand="sp_GetDepartments" SelectCommandType="StoredProcedure"></asp:SqlDataSource>
<
asp:DropDownList ID="delcode" runat="server" DataSourceID="getDept" AppendDataBoundItems="true"DataTextField="head1" DataValueField="delcode" AutoPostBack="true">
<asp:ListItem Text="Please select Department..." Value="" />
</asp:DropDownList>

<asp:DropDownList ID="EmployeeID" runat="server" AppendDataBoundItems="true" DataSourceID="getEmployeeByDept" DataTextField="FullName" DataValueField="TKINIT">
<asp:ListItem Text="Please select Employee..." Value="" />
</asp:DropDownList>

and my code behind...

Protected Sub delcode_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles delcode.SelectedIndexChanged

EmployeeID.Items.Clear()
EmployeeID.DataBind()
EmployeeID.AppendDataBoundItems =
True

End Sub


Never make important decisions on a Monday!
0
funluckykitty
1/13/2009 8:22:41 PM
asp.net.getting-started 91979 articles. 4 followers. Follow

6 Replies
880 Views

Similar Articles

[PageSpeed] 29
Get it on Google Play
Get it on Apple App Store

 try to set the value as -1

value="-1"

 


Thanks,
Karan

~ Remember To Mark The Post(s) That Helped You As The ANSWER ~
0
karan
1/13/2009 8:41:43 PM

hmmm.. added the following line to my codebehind, and it seems to work... hope this is right.. :-)

 

EmployeeID.SelectedItem.Text = "Please select Employee..."


Never make important decisions on a Monday!
0
funluckykitty
1/13/2009 8:46:35 PM

 well as I mentioned above you can do that:

<asp:ListItem Text="Please select Department..." Value="-1" /> </asp:DropDownList>

This should work, instead of specifying it in code behind.


Thanks,
Karan

~ Remember To Mark The Post(s) That Helped You As The ANSWER ~
0
karan
1/13/2009 8:47:58 PM

That's because you cleared out the items in the List.. You need to re-attach the "Please Select" item again after you call DataBind..

 

Protected Sub delcode_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles delcode.SelectedIndexChanged
    EmployeeID.Items.Clear() 
    EmployeeID.DataBind() 
    EmployeeID.Items.Insert(0, New ListItem("Plese Select", "Plese Select")) 
End Sub 
 

Regards,Vinz

"Code, Beer and Music" that's my way of being a programmer!

How to get your Forum Question Answered | Blog | CodeASP.NET
0
vinz
1/13/2009 8:50:30 PM

Ah ha!  Thank you vinz... you're right.. it was getting cleared each time.. didn't realize I needed to add it back in from the codebehind.  Thank you!!!


Never make important decisions on a Monday!
0
funluckykitty
1/13/2009 9:13:27 PM

funluckykitty:
Ah ha!  Thank you vinz... you're right.. it was getting cleared each time.. didn't realize I needed to add it back in from the codebehind.  Thank you!!!
 

Welcome! Glad to be of help!


Regards,Vinz

"Code, Beer and Music" that's my way of being a programmer!

How to get your Forum Question Answered | Blog | CodeASP.NET
0
vinz
1/13/2009 9:15:29 PM
Reply:

Similar Artilces:

Gridview height="300px" works but height="40%" doesn't work
I want to divide to top-half (40%), bottom-half(60%). So I can put a gridview in top-half with scroll and put a chart in bottom-half. So when users with different resolution can see same table layout. But the problem is that if I set the gridview as pixel(such as 300px), it works. If I put the percentage(such as 40%), gridview just shows the whole data(which is more than 40% of height) even thought it supposed to limit its hieght to 40% and make it scrollable. I tried to do stuff in css and everything I know, it's not working. Somebody please help me with this!   Trying re...

"Add View" Dialog doesn't show my models in the "View data class" drop down list.
My models are in a separate project which my MVC Web Application references.   When I go Add -> View, the "Add View" dialog does not contain any of my models.  It does however contain other classes from other referenced projects and libraries.  The MVC Web App compiles cleanly with no errors or warnings and my model types are visible to the controlers.What am I missing? dw Hi I'm following up on this. For now you should be able to work around this by typing the name of the model in the dialog. Jacques Hi Cyberfloatie, Do your models come from an assembl...

Doesn't work when you select "ok" from a drop down window to upload files on verious sites
Name: Timothy Kavmark Email: tkavmarkataoldotcom Product: Firefox Summary: Doesn't work when you select "ok" from a drop down window to upload files on verious sites Comments: When selecting an option from a drop down window (like selecting and image for upload on eBay or on the software my company uses: www.basecamphq.com) it doesn't except when you click "OK" or "Upload". You have to first click "OK" then click back onto the original site for it to work. Browser Details: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US;...

Precedence of "where" ("of", "is", "will")?
Nobody on #perl6 today could answer this one. Is: Str | Int where { $_ } the same as: (Str | Int) where { $_ } or: Str | (Int where { $_ }) ? Followup questions, Mr. President: What kind of operators are "where", "of", "is", and "will"? Is there a reason that S03 doesn't list them? What are their precedence(s)? -- Chip Salzenberg - a.k.a. - <chip@pobox.com> Open Source is not an excuse to write fun code then leave the actual work to others. Chip Salzenberg writes: &...

.ALLCOL("%COLUMN%", " ", ", ", ", ")
Do you know anyway for me to exclude a subset of columns returned by this function. We have two columns (rec_user and rec_datetime) which are in all of our tables, but when generating triggers I want automatically generate a script which does not include those two columns but does include all other columns in that table. Bruce I should add that I am using PD 9.0.0.580. Bruce "Bruce Lamb" <lamb.bruce@mayo.edu> wrote in message news:6HgI315nCHA.155@forums.sybase.com... > Do you know anyway for me to exclude a subset of columns returned by this > function. ...

superreview requested: [Bug 180239] Manual "Run selected filter(s)" doesn' t work when multiple filters are selected.
Karsten D=C3=BCsterloh <mnyromyr@tprac.de> has asked David Bienvenu <bienvenu@nventure.com> for superreview: Bug 180239: Manual "Run selected filter(s)" doesn't work when multiple filt= ers are selected. https://bugzilla.mozilla.org/show_bug.cgi?id=3D180239 Attachment 255714: fix index handling https://bugzilla.mozilla.org/attachment.cgi?id=3D255714&action=3Dedit ------- Additional Comments from Karsten D=C3=BCsterloh <mnyromyr@tprac.de> This is so sad. For about 5 years nobody can't even have looked into the co= de, since the actual bug i...

superreview granted: [Bug 180239] Manual "Run selected filter(s)" doesn' t work when multiple filters are selected.
David Bienvenu <bienvenu@nventure.com> has granted Karsten D=C3=BCsterloh <mnyromyr@tprac.de>'s request for superreview: Bug 180239: Manual "Run selected filter(s)" doesn't work when multiple filt= ers are selected. https://bugzilla.mozilla.org/show_bug.cgi?id=3D180239 Attachment 255714: fix index handling https://bugzilla.mozilla.org/attachment.cgi?id=3D255714&action=3Dedit ------- Additional Comments from David Bienvenu <bienvenu@nventure.com> thx, karsten!= ...

Get "Mail"/"Get "News" / "Write"/"Post" buttons?
If the "Get Mail" button text changed to "Get News", and "Write" changed to "Post" when TB's in the news-reading mode, it would save me and probably others from constantly forgetting to make the change before proceeding. :-) Or is there an extension to do this which I don't know about? Thanks! Bob Bob P wrote: > If the "Get Mail" button text changed to "Get News", and "Write" > changed to "Post" when TB's in the news-reading mode, it would save me > and probably others...

Alps touchpad "back" and "forward" gesture doesn't work
Name: PGG Email: petergeorgegoetz at netscape.net Product: Firefox Summary: Alps touchpad "back" and "forward" gesture doesn't work Comments: The Alps touchpad is set up to use the scroll area at the top of the pad as "back" and "forward" controls for browsers. Scrolling a page up and down DOES work with touchpad gestures. It works with IE 6.0, but doesn't work with any Firefox version. BTW, it doesn't work with Opera 8.5 either. The Alps driver is 5.4.102.12. I've seen lots of requests for help with thi...

"Change columns" and "Remember search" doesn't work in Bugzilla
hi, "Change columns" and "Remember search" doesn't work in Bugzilla. Clicking on these buttons throws "Page cannot be displayed Technical Information (for support personnel) Error Code: 500 Internal Server Error. The request was rejected by the HTTP filter. Contact the server administrator. (12217) " I am using Bugzilla version 2.22.7, Bugzilla is hosted on Linux server. Any hint on this problem will be of great help. thanks & regards Dhananjaya Guten Tag chintu apr, am Freitag, 13. Juli 2012 um 07:23 schrieben ...

quotes, quotes, quotes...
I am getting this error and I know what is causing it, but I have no idea how to fix it, any help would be great. The script steps through the /var/log/messages file on a linux server and puts The entries into a mysql database. However when it gets to the 'hlt' line in the messages file it just barfs. The single quotes are freaking it out. I know about quotes but not how to use in this situation. Thanks, Paul Error: May 27 17:53:00 localhost kernel: Checking 'hlt' instruction... OK. <----- doesn't like this in the messages file DBD::mysql::st exec...

FF 3 beta 3
Name: Jeff Reynolds Email: jeffdotkvnfatgmaildotcom Product: Firefox Release Candidate Summary: FF 3 beta 3 - "send link" or "mailto:" doesn't work if T-Bird already running Comments: Howdy! If Thunderbird is already running, Firefox3 b3 returns an error message if a "mailto:" link is clicked or the "Send Link" menu item is selected. text: "Thunderbird is already running but is not responding. To open a new window you must first close the existing Thunderbird process or restart your system." Win XP, T-Bird 2.0.0.9, Fir...

Like "'" + Billtocompany + "%'" does not work
Dear All,  I have put the following code and not records returned. Do you know Why? Even I have set the variables to be empty string. SQL Data Source: <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:THL2ConnectionString %>"     SelectCommand="SELECT BLInv.InvNo, .....from ...... WHERE (BLInv.BilltoCompany like @BillToCompany) AND (BLInv.CountryCode like @CountryCode) AND (BLInv.Quarter like @Quarter)">        <SelectParameter...

"View Image" works, "Show Image" doesn't, in www.shilohproject.com
Name: David Beaucage Email: ShilohProjectatgmaildotcom Product: Firefox Summary: "View Image" works, "Show Image" doesn't, in www.shilohproject.com Comments: These images are Flash Text, installed through Dreamweaver. There may be something wrong with my settings as related to viewing images, independent of Firefox 3 -- something I did in Firefox 2 made the comic-strip images in Comics.com disappear and remain invisible whatever I did. The other images behaved like the Flash Text in ShilohProject.com. Browser Details: Mozilla/5.0 (Windows; U; Windo...

Web resources about - AppendDataBoundItems="true" doesn't work for 2nd drop down box that is "filtered" based on selection of first drop down box. - asp.net.getting-started

Resources last updated: 12/26/2015 5:12:21 AM