Checkbox list

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Nov 2009
Posts: 16
Reputation: RAMAN2233 is an unknown quantity at this point 
Solved Threads: 0
RAMAN2233 RAMAN2233 is offline Offline
Newbie Poster

Checkbox list

 
0
  #1
25 Days Ago
How to display checkbox list in a panel??
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 439
Reputation: Ramesh S will become famous soon enough Ramesh S will become famous soon enough 
Solved Threads: 82
Ramesh S Ramesh S is offline Offline
Posting Pro in Training
 
0
  #2
25 Days Ago
Do you mean ASP.NET Panel control or UpdatePanel?

If ASP.NET Panel, it is rendered as DIV at run time. Apart from that there won't be any issues when displaying a CheckBoxList inside a Panel or without Panel.

Check this code.

.aspx code
  1. <%@ Page Language="C#" AutoEventWireup="true" CodeFile="DemoPage38.aspx.cs" Inherits="DemoPage38" %>
  2.  
  3. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  4. <html xmlns="http://www.w3.org/1999/xhtml">
  5. <head runat="server">
  6. <title></title>
  7. </head>
  8. <body>
  9. <form id="form1" runat="server">
  10. <div>
  11. <table width="100%">
  12. <tr>
  13. <td>
  14. <asp:Panel ID="Panel1" runat="server">
  15. <asp:CheckBoxList ID="cblBooks" runat="server">
  16. </asp:CheckBoxList>
  17. </asp:Panel>
  18. </td>
  19. </tr>
  20. </table>
  21. </div>
  22. </form>
  23. </body>
  24. </html>

C# Code

  1. using System;
  2. using System.Data;
  3.  
  4. public partial class DemoPage38 : System.Web.UI.Page
  5. {
  6. protected void Page_Load(object sender, EventArgs e)
  7. {
  8. if (!IsPostBack)
  9. {
  10. BindCheckBoxList();
  11. }
  12. }
  13. private void BindCheckBoxList()
  14. {
  15.  
  16. //You can load the following DataTable from a database
  17. DataTable dtBooks = new DataTable();
  18.  
  19. dtBooks.Columns.Add("Book_Id", System.Type.GetType("System.Int32"));
  20. dtBooks.Columns.Add("Book_Name", System.Type.GetType("System.String"));
  21.  
  22. dtBooks.Rows.Add(new object[] { 100, "ASP.NET Programming" });
  23. dtBooks.Rows.Add(new object[] { 101, "Beginning Web Development" });
  24. dtBooks.Rows.Add(new object[] { 102, "ASP.NET for Dummies" });
  25. dtBooks.Rows.Add(new object[] { 103, "SharePoint 2007" });
  26. dtBooks.Rows.Add(new object[] { 104, "PHP Programming" });
  27.  
  28. //Binding DataTable to the CheckBoxList control
  29. cblBooks.DataSource = dtBooks;
  30. cblBooks.DataTextField = "Book_Name";
  31. cblBooks.DataValueField = "Book_Id";
  32. cblBooks.DataBind();
  33.  
  34. }
  35. }
Last edited by Ramesh S; 25 Days Ago at 8:32 am.
Reply With Quote Quick reply to this message  
Join Date: Nov 2009
Posts: 16
Reputation: RAMAN2233 is an unknown quantity at this point 
Solved Threads: 0
RAMAN2233 RAMAN2233 is offline Offline
Newbie Poster

Checkboxlist

 
0
  #3
24 Days Ago
Sorry buddy it isnt panel its a template........i want to display checkboxlist ina template.
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 439
Reputation: Ramesh S will become famous soon enough Ramesh S will become famous soon enough 
Solved Threads: 82
Ramesh S Ramesh S is offline Offline
Posting Pro in Training
 
0
  #4
24 Days Ago
Which template?

Do you want to display it in template column in a GridView/DataList/Repeater or in a ContentTemplate?

Please provide more information in detail. It will help you to get a answer from someone soon.
Reply With Quote Quick reply to this message  
Reply

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC