問題描述
單步執行控件看不到第二個下拉菜單 (Step through controls fail to see second dropdown)
I have an ASP.net table. In several cells I have two dropdown lists. The item selected in each dropdownlist is supposed to be populated from an SQLServer 2005 database. To do this in my code behind I step through the controls in each table cell. The code sees the first dropdown and populates it and then goes to the next cell.
My ASP
<asp:TableRow runat="server" ID="rowEnglish">
<asp:TableCell ID="celCourseEnglish" runat="server">
<asp:DropDownList ID="ddlCourseEnglish" runat="server" AutoPostBack="True">
<asp:ListItem Value="0">English</asp:ListItem>
</asp:DropDownList>
<br />
<asp:DropDownList ID="ddlCommentEnglish" runat="server" Font‑Size="X‑Small" DataSourceID="sqlDS_comment" DataTextField="comment" DataValueField="id" Width="125px">
</asp:DropDownList>
my VB
For Each rowTemp In dtScores.Rows
Dim tblRow As TableRow
For Each tblRow In tblProgReport.Rows
Dim celTemp As New TableCell
For Each celTemp In tblRow.Cells
Dim ctl As Control
For Each ctl In celTemp.Controls
If TypeOf ctl Is DropDownList Then
Dim ddlTemp As DropDownList = CType(ctl, DropDownList)
'select value from dropdown list
I've tried changing the order of the controls in the cell, with the course dropdown still being the one seen. Tried removing the course dropdown and then the comment dropdown displays correctly. The whole thing is in a content placeholder from a master page. Not sure why the second dropdown is not being seen.
Thanks
‑‑‑‑‑
參考解法
方法 1:
You may have to post your complete VB code. What are you doing once you find it? You are continuing in your foreach correct? You are not breaking out of it?
(by monkeypushbutton、Keplerf1)