2
Contributors
3
Replies
5
Views
7 Years
Discussion Span
Last Post by Ramesh S
0

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

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DemoPage38.aspx.cs" Inherits="DemoPage38" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <table width="100%">
            <tr>
                <td>
                    <asp:Panel ID="Panel1" runat="server">
                        <asp:CheckBoxList ID="cblBooks" runat="server">
                        </asp:CheckBoxList>
                    </asp:Panel>
                </td>
            </tr>
        </table>
    </div>
    </form>
</body>
</html>

C# Code

using System;
using System.Data;

public partial class DemoPage38 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindCheckBoxList();
        }
    }
    private void BindCheckBoxList()
    {

        //You can load the following DataTable from a database
        DataTable dtBooks = new DataTable();

        dtBooks.Columns.Add("Book_Id", System.Type.GetType("System.Int32"));
        dtBooks.Columns.Add("Book_Name", System.Type.GetType("System.String"));

        dtBooks.Rows.Add(new object[] { 100, "ASP.NET Programming" });
        dtBooks.Rows.Add(new object[] { 101, "Beginning Web Development" });
        dtBooks.Rows.Add(new object[] { 102, "ASP.NET for Dummies" });
        dtBooks.Rows.Add(new object[] { 103, "SharePoint 2007" });
        dtBooks.Rows.Add(new object[] { 104, "PHP Programming" });

        //Binding DataTable to the CheckBoxList control
        cblBooks.DataSource = dtBooks;
        cblBooks.DataTextField = "Book_Name";
        cblBooks.DataValueField = "Book_Id";
        cblBooks.DataBind();

    }
}

Edited by Ramesh S: n/a

0

Sorry buddy it isnt panel its a template........i want to display checkboxlist ina template.

0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.