G
Guest
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.AppSettings("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.GetString(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
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.AppSettings("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.GetString(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