codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  Dropdownlist Database Connection  MBDesktop at 02:19 on Monday, December 20, 2004
 

Consider in a page i have two dropdown list. First dropdownlist displays DESCRIPTION and depending upon the selection of DESCRIPTION in first dropdownlist, i need to display DESCRIPTION SUMMARY in second dropdownlist. All of the data i get from SQL Server 2000 database.

First Dropdownlist SQL connection ( Success )-->
Const strSQL As String = "sp_GParam 'SELECT', '45', '', '', '', '', '', ''"

Second Dropdownlist ( Failed )-->
Dim SQLstr As String = "sp_GParam 'SELECT', '" & "ddlMainCat" & "', '', '', '', '', '', ''"

In the second dropdownlist, i want to populate the data by refer in first dropdownlist.


i want to use this method-->

After selecting a value from the DESCRIPTION dropdownlist. i can do a postback and get the data for DESCRIPTION SUMMARY and bind it to the other dropdown. This method involves a page refresh. All the controls in the page have to be refreshed and whatever data entered has to be retained.user has to wait till the page loads for entering other data in the page.

So can i discuss about all of it with anybody. I need to be more experiences in asp.net because i'm really beginner in asp.net.


  Re: Dropdownlist Database Connection  Granby at 22:41 on Wednesday, January 26, 2005
 

Hide the second dropdownlist (visible=false) on the page load event, when there is no postback. Something like the following in Page_Load.

if ispostback=false
list2.visible = false
end if


In the postback function of the first dropdown list, fill the second dropdownlist and make it visible. I put a button next the list to post it, as well as setting autopostback="True" in the list itself. This makes for a pretty sharp form, and resets list 2 if they change list 1, which is often imoportant.



Just a tip, a little known feature in asp.net is the asp panel. This panel is great way to hide and make visible lots of controls at once.

example code
<ASP:Panel id="pnParameters" runat="server" >
'put lots of controls here
</asp:panel>

Now, one can just set pnParamters.visible=true (or false) to show/hide whole portions of the page. This may come in handy for what you are trying to do, especially if you start linking three or four lists together.

Good luck



© Copyright codetoad.com 2001-2005