AboutSyed Rizwan Muhammad Rizvi Expertise I can answers questions regarding web based and desktop based programming in VB.Net. Which can include SOAP, XML, Custom Controls, COM Interoperability etc.
Experience Have been working in this specific area for last 2 years previously I was a VB 6 Developer with experties in other languages as well. Total 10 years of programming experience.
Expert: Syed Rizwan Muhammad Rizvi Date: 10/19/2006 Subject: How to add checkboxes and table at run time in panel control in asp.net
Question still i am getting no error but no output
-------------------------------------------
The text above is a follow-up to ...
-----Question-----
i am developing web based application in asp.net, i want to add checkboxes in first column and then rest of the fields in other column of the table at run time in panel. but i am unable to do here is the code. first i am preparing datareader and then depending upon no. of records in datareader i have add checkboxes and other fields in the table and then add this table to panel 'pnlagency'.
strconn = "data source=tajwar;initial catalog=ssca;user id=ssca;password=ssca2005"
conn = New SqlConnection(strconn)
conn.Open()
strsql = "SELECT * FROM ((pa_registration AS pr LEFT JOIN Producing_Agency AS pa ON pr.pa_id=pa.pa_id and pr.period_id=pa.period_id )" _
& " left join district on pa.pa_distt_id=district.distCode) where pr.period_id = '" & Session("year_code") & "' Order by pa_name,Distname"
cmdsql = New SqlCommand(strsql, conn)
dr = cmdsql.ExecuteReader()
Dim chklist As New CheckBoxList
chklist.ID = "chklst"
chklist.DataValueField = "pa_id"
chklist.DataTextField = "pa_name"
chklist.DataSource = dr
chklist.DataBind()
'Pnlagency.Controls.Add(chklist)
Dim table9 As Table
Dim trow As New TableRow
Dim tcell As New TableCell
' Pnlagency.Controls.Add(trow)
'Pnlagency.Controls.Add(tcell)
If dr.HasRows Then
While dr.Read
tcell.Controls.Add(chklist)
trow.Cells.Add(tcell)
table9.Rows.Add(trow)
End While
End If
Pnlagency.Controls.Add(table9)
-----Answer-----
I think this code should crash, you are missing a new before table it should be:
Dim table9 as New Table
And I would recommend that you use datarepeater control rather than this way of doing it.
Answer please use datarepeater control instead, this will keep giving you problems.