// default.aspx //
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="default.aspx.cs" Inherits="default" %>
<!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">
<style type="text/css">
.PnlDesign
{
border: solid 1px #000000;
height: 150px;
width: 330px;
overflow-y:scroll;
background-color: #EAEAEA;
font-size: 15px;
font-family: Arial;
}
</style>
</style>
</head>
<body>
<form id="form1" runat="server">
<asp:CheckBoxList ID="CheckBoxList1" runat="server" RepeatColumns="1"
style="position:absolute; top: 890px; left: 10px; height: 699px; width: 257px;"
AutoPostBack="True" CellSpacing="1" CssClass="PnlDesign">
</asp:CheckBoxList>
</form>
</body>
</html>
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="default.aspx.cs" Inherits="default" %>
<!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">
<style type="text/css">
.PnlDesign
{
border: solid 1px #000000;
height: 150px;
width: 330px;
overflow-y:scroll;
background-color: #EAEAEA;
font-size: 15px;
font-family: Arial;
}
</style>
</style>
</head>
<body>
<form id="form1" runat="server">
<asp:CheckBoxList ID="CheckBoxList1" runat="server" RepeatColumns="1"
style="position:absolute; top: 890px; left: 10px; height: 699px; width: 257px;"
AutoPostBack="True" CellSpacing="1" CssClass="PnlDesign">
</asp:CheckBoxList>
</form>
</body>
</html>
// default.aspx.cs //
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Drawing;
public partial class default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
FillQualCheckBoxList();
}
}
private void FillQualCheckBoxList()
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["Pubs"].ConnectionString);
SqlCommand cmd = new SqlCommand("Select * from category", con);
SqlDataAdapter adp = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
adp.Fill(dt);
cblCourses.DataSource = dt;
cblCourses.DataTextField = "Name";
cblCourses.DataValueField = "Id";
cblCourses.DataBind();
}
// Add Code in web.config //
<connectionStrings>
<add name="Pubs" connectionString="Data Source=.;Initial Catalog=rnp;Integrated Security=True"/>
</connectionStrings>
// SQL Table //
No comments:
Post a Comment