AllExperts > Experts 
Search      

VB.NET

Volunteer
Answers to thousands of questions
 Home · More Questions · Answer Library  · Encyclopedia ·
More VB.NET Answers
Question Library

Ask a question about VB.NET
Volunteer
Experts of the Month
Expert Login

Awards

About Us
Tell friends
Link to Us
Disclaimer

 
 
 
 
About Syed 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.

 
   

You are here:  Experts > Computing/Technology > Basic > VB.NET > How to add checkboxes and table at run time in panel control in asp.net

Topic: VB.NET



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.

This is a very good tutorial on repeater control: http://www.w3schools.com/aspnet/aspnet_repeater.asp

if you still insist on not using data repeater let me know I will find a way out for you.

By the way are you sure that dr has got some rows in it may be the loop isnt working.

Add to this Answer    Ask a Question



  Rate this Answer
   Was this answer helpful?
Not at allDefinitely              
   12345  

     
About Us | Advertise on This Site | User Agreement | Privacy Policy | Help
Copyright  © 2008 About, Inc. About and About.com are registered trademarks of About, Inc. The About logo is a trademark of About, Inc. All rights reserved.