B
Bryan Donaldson
I have a table on my web form, declared like this:
<asp:table id="tblOverrides" runat="server" enableviewstate=true"
cssclass="clsTable">
<asp:tablerow cssclass="clsTblHeader">
<asp:tablecell Text="label" id="hdrLabel"></asp:tablecell">
<asp:tablecell Text="ddl" id="hdrDDL"></asp:tablecell">
</asp:tablerow>
</asp:table>
-----------------------------------------------------------------------
In a click event for a check box, I have code that looks like this, to add
label text in one column and a drop down list in another. (Btw - there are
LOTS of examples of this...)
-----------------------------------------------------------------------
dim i,j as integer
for i = 1 to 10
dim oRow as new Tablerow
oRow.EnableViewState=true
dim oLabelCell as new TableCell
oLabelCell.text = i.tostring
dim oDDLCell as new TableCell
dim oDDL as system.web.ui.webcontrols.dropdownlist
ddl.Items.clear()
ddl.Items.Add("")
for j = 0 to i
ddl.Items.Add(J.ToString)
next
oDDLCell.Controls.Add(oDDL)
oRow.Cells.Add(oLabelCell)
oRow.Cells.Add(oDDLCell)
tblOverrides.Rows.Add(oRow)
next
-----------------------------------------------------------------------
Now, in a button click event handler, I want to retrieve the selected values
from the drop down lists.
I thought something like this would work :
for n = 2 to tblOverrides.Rows.Count
dim oDDL as new system.web.ui.webcontrols.dropdownlist
oDDL = tblOverrides.Rows(n).Cells(1).Controls(0)
sum += cInt(oDDL.SelectedValue)
next
however, the tblOverrides.Rows.Count is never more than 1. What do I have
to do to be able to refer to cells I dynamically created on a later trip to
the server?
<asp:table id="tblOverrides" runat="server" enableviewstate=true"
cssclass="clsTable">
<asp:tablerow cssclass="clsTblHeader">
<asp:tablecell Text="label" id="hdrLabel"></asp:tablecell">
<asp:tablecell Text="ddl" id="hdrDDL"></asp:tablecell">
</asp:tablerow>
</asp:table>
-----------------------------------------------------------------------
In a click event for a check box, I have code that looks like this, to add
label text in one column and a drop down list in another. (Btw - there are
LOTS of examples of this...)
-----------------------------------------------------------------------
dim i,j as integer
for i = 1 to 10
dim oRow as new Tablerow
oRow.EnableViewState=true
dim oLabelCell as new TableCell
oLabelCell.text = i.tostring
dim oDDLCell as new TableCell
dim oDDL as system.web.ui.webcontrols.dropdownlist
ddl.Items.clear()
ddl.Items.Add("")
for j = 0 to i
ddl.Items.Add(J.ToString)
next
oDDLCell.Controls.Add(oDDL)
oRow.Cells.Add(oLabelCell)
oRow.Cells.Add(oDDLCell)
tblOverrides.Rows.Add(oRow)
next
-----------------------------------------------------------------------
Now, in a button click event handler, I want to retrieve the selected values
from the drop down lists.
I thought something like this would work :
for n = 2 to tblOverrides.Rows.Count
dim oDDL as new system.web.ui.webcontrols.dropdownlist
oDDL = tblOverrides.Rows(n).Cells(1).Controls(0)
sum += cInt(oDDL.SelectedValue)
next
however, the tblOverrides.Rows.Count is never more than 1. What do I have
to do to be able to refer to cells I dynamically created on a later trip to
the server?