943,973 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Unsolved
  • Views: 1261
  • ASP.NET RSS
Nov 10th, 2009
0

Checkbox list

Expand Post »
How to display checkbox list in a panel??
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
RAMAN2233 is offline Offline
19 posts
since Nov 2009
Nov 10th, 2009
0
Re: Checkbox list
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
ASP.NET Syntax (Toggle Plain Text)
  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

ASP.NET Syntax (Toggle Plain Text)
  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; Nov 10th, 2009 at 8:32 am.
Reputation Points: 165
Solved Threads: 113
Posting Pro
Ramesh S is offline Offline
580 posts
since Jun 2009
Nov 11th, 2009
0

Checkboxlist

Sorry buddy it isnt panel its a template........i want to display checkboxlist ina template.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
RAMAN2233 is offline Offline
19 posts
since Nov 2009
Nov 11th, 2009
0
Re: Checkbox list
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.
Reputation Points: 165
Solved Threads: 113
Posting Pro
Ramesh S is offline Offline
580 posts
since Jun 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: Export Lable text into Excel
Next Thread in ASP.NET Forum Timeline: Transfer data between pages





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC