mRbLACK Posted February 16, 2004 Posted February 16, 2004 ok this might be a long one but should be interesting enough... im building a function that generates a table populated with text and web controls (buttons/textboxes...) these have been declared at the top of my page already for use on the page, they have events of their own etc.... Protected WithEvents tdRightBar As System.Web.UI.HtmlControls.HtmlTableCell Protected WithEvents txtSearch As New System.Web.UI.WebControls.TextBox Now this table that is generated is made as a stringbuilder then added to the tdRightBAr as we go along, so build the <tr><td> tags add text etc. then add to the panel as a literal control oPanel.Controls.Add(New LiteralControl(sTable.ToString)) then i would add the txtSearch control or whatever usually like this... tdLeftBar.Controls.Add(txtSearch) which would work fine...except that now im passing all these values in an array to a fucntion which is then supposed to add them...but when it gets into the funtion and adds them for some reason it wont add the controls, im assuming becuase the array doesnt hold a reference to the actual controls but makes it of same type (which doesnt carry the events etc. of my declared ones...) so the question is how can i add the controls/ pass them in such a way that it does keep the reference to my declared controls and not try add add some fake control of same type heres some more code i know its kinda confusing... '-- Building array / sending to function... Dim oValues(2, 1) As Object oValues(0, 0) = "Search" '-- Some text oValues(1, 0) = "Keywords" oValues(1, 1) = txtSearch '-- Controls oValues(2, 0) = btnSearch AddDynamicTable(oValues, tdLeftBar) '-- Send which panel to add to '-- Receiving Function and adding code... Private Function AddDynamicTable(ByRef aValues(,) As Object, ByRef oPanel As System.Web.UI.HtmlControls.HtmlTableCell) Dim sTable As New System.Text.StringBuilder Dim i, j As Integer sTable.Append("<table class='tblFunction' cellpadding=0 cellspacing=0") For i = 0 To UBound(aValues, 1) sTable.Append(sOPENROW) For j = 0 To UBound(aValues, 2) If (aValues(i, 0) Is Nothing And Not aValues(i, 1) Is Nothing) Or _ (Not aValues(i, 0) Is Nothing And aValues(i, 1) Is Nothing) Then sTable.Append(sOPENCOLSPAN) If aValues(i, j).GetType() Is System.Type.GetType("System.String") Then sTable.Append(aValues(i, j)) Else oPanel.Controls.Add(New LiteralControl(sTable.ToString)) oPanel.Controls.Add(aValues(i, j)) sTable = New System.Text.StringBuilder("") End If j += 1 Else '---- Bla Bla Bla, the rest is basically the same as above... Thanks for any help in advance :p Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.