Active Server Pages Programming (ASP)/About ASP.net DropDownlist
Expert: Srini Nagarajan - 7/23/2007
QuestionQUESTION: Hi, i just wondering how can i put 5 dropdownlists by using for loop or else?? And how can i request it??
hope you understand what i'm doing below
<%
2
3 For i = 1 To 5
4 tempdate = DateAdd(DateInterval.Day, 0 + i - 1, startdate)
5 Response.Write("<tr>")
6 Response.Write("<td style='width: 64px;background-color: #ffffcc;'>")
7 Response.Write(Format(tempdate, "M/d") & "</td>")
8 Response.Write("<td style='width: 65px'><img src='images/" & tempdate.DayOfWeek + 1 & ".gif' /></td>")
9 Response.Write("<td style='width: 202px'>")
10
11 %>
12
13 <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="FALSE" DataSourceID="SqlDataSource1" DataTextField="F121_01" DataValueField="F121_07">
14
15 </asp:DropDownList>
16 <%
17 Response.Write("</td>")
18 Response.Write("</tr>")
19 Next
ANSWER: Hi
I understand the first part of it, but i don't understand in dropdown area..
what are you trying to do in dropdownlist? is sqldatasource1 where the data come from? do you have a sqldatasource created?
what error you are getting
let me know so that I can give tell you what need to be modified.
-srini
---------- FOLLOW-UP ----------
QUESTION: actually, there is no error but. As you see DropDownList ID="DropDownList1", it means there are 5 dropdownlists were created but all in the same id. and i need to request each dropdownlist value.
AnswerHi
You can put in a repeater control to get the value or
You can create a javascript for each onselect you can find which drop down and store into a local hidden variable.
Once you run thru javascript you can get the value in you code once the user submit..
Happy programming!!
=srini