Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP:DropDownList Question

Reply
Thread Tools

ASP:DropDownList Question

 
 
Guest
Posts: n/a
 
      10-29-2003

Hi All

I have a form in which i build a table for a series of twenty questions,
like a survey questionaire.

I use the following function in a user control to create the DropdownList
from the DB and in the loop that builds the table cells i call the function
each time:

Public Function Get_MultiDDL() As DropDownList

Dim drDDLValues As SqlHelper
Dim drDDLValuesList As SqlDataReader
Dim i As Integer = 0
ddlListBoxMulti = New DropDownList

i = 0
drDDLValuesList =
drDDLValues.ExecuteReader(ConfigurationSettings.Ap pSettings("SQLServer"),
CommandType.StoredProcedure, "csp_SELECT_Answer_Multi")
ddlListBoxMulti.Items.Add(" ")
ddlListBoxMulti.Items(i).Value() = 0
i += 1

Do While drDDLValuesList.Read()

ddlListBoxMulti.Items.Add(drDDLValuesList.GetStrin g(1))
ddlListBoxMulti.Items(i).Value() = drDDLValuesList.GetInt32(0)
i += 1
Loop
i = 0

drDDLValuesList.Close()
drDDLValuesList = Nothing
drDDLValues = Nothing
Return ddlListBoxMulti

End Function


Is there a better way to make one call and have the Dropdownlist available
thruout the function that builds the table?
What i am doing now is, as the loop executes, the function is called and it
returns a dropdownlist. I would think i would be able to make one call to
the DB, and have the DropDownlist available, instead of calling the function
20 times as the table cells are built.

thanks in advance





--
The Mighty Thor Lives
http://www.themightythor.com


 
Reply With Quote
 
 
 
 
AW
Guest
Posts: n/a
 
      10-29-2003
> I have a form in which i build a table for a series of twenty questions,
> like a survey questionaire.
>
> ...
> Dim drDDLValues As SqlHelper
> Dim drDDLValuesList As SqlDataReader
> ...
> Do While drDDLValuesList.Read()
>
> ddlListBoxMulti.Items.Add(drDDLValuesList.GetStrin g(1))
> ...
>
> Is there a better way to make one call and have the Dropdownlist available
> thruout the function that builds the table?


How about binding the drDDLValuesList DataReader to the DropDownList? You
set the DataSource to drDDLValuesList, set the DataTextField to the column
name of the second column, and you're done. Don't forget to call DataBind()
on the control.
---
To reply, remove a "l" before the @ sign.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
question row filter (more of sql query question) =?Utf-8?B?YW5kcmV3MDA3?= ASP .Net 2 10-06-2005 01:07 PM
Quick Question - Newby Question =?Utf-8?B?UnlhbiBTbWl0aA==?= ASP .Net 4 02-16-2005 11:59 AM
Question on Transcender Question :-) eddiec MCSE 6 05-20-2004 06:59 AM
Question re: features of the 831 router (also a 924 question) Wayne Cisco 0 03-02-2004 07:57 PM
Syntax Question - Novice Question sean ASP .Net 1 10-20-2003 12:18 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57