|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
|
data from a control on a different page. My code is below. It is working perfectly fine, but since I have 10 more label to check is it some how I can make this code is more compact? If CType(myconrtol.FindControl("lblCompany"), Label).Visible = True Then dr(0) = CType(myconrtol.FindControl ("lblCompany"), Label).Text() dr(1) = myconrtol.Company dt.Rows.Add(dr) dr = dt.NewRow() End If If CType(myconrtol.FindControl("lblPlanName"), Label).Visible = True Then dr(0) = CType(myconrtol.FindControl ("lblPlanName"), Label).Text() dr(1) = myconrtol.PlanName dt.Rows.Add(dr) dr = dt.NewRow() End If Hello,
Assuming these controls are all part of a page, try looping through all of the controls on the page... For Each ctl In Me.Controls(1).Controls Try ... Catch End Try Next Jason But I do I get to this code?
dr(0) = CType(mycontrol.FindControl("lblCompany"), Label).Text() dr(1) = mycontrol.Company dt.Rows.Add(dr) Here is what I did based on your post, however I am not
getting back the right controls name in custom mycontrols. For Each ctl In mycontrols.Controls 'Me.Controls (1).Controls Dim tb As Label Dim tx As TextBox If TypeOf ctl Is Label Then tb = CType(ctl, Label) dr(0) = tb.Text ElseIf TypeOf ctl Is TextBox Then tx = CType(ctl, TextBox) dr(0) = tx.Text Else End If dt.Rows.Add(dr) dr = dt.NewRow() Next
UserControl inside of datagrid - loses its viewstate when datagrid is re-bound on postback
iterate through only one column of a datagrid Annoyingly simple problem _EditCommand not firing... Access individual item in a datagrid Datagrid sorting does not work Group Headers in Datagrid Can't get text value of hidden (visible = false) column.. Check Parent-child relationship in datagrid Container |
|||||||||||||||||||||||