CHECK BOX LIST BINDING FROM DATA BASE


CodeFile

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class CheckBoxList : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        SqlConnection con = new SqlConnection("Trusted_Connection=true;DataBase=Praveen_DataBase");
        SqlDataAdapter da = new SqlDataAdapter("Select * from Table1", con);
        DataSet ds = new DataSet();
        da.Fill(ds);
        CheckBoxList1.DataSource = ds;
        CheckBoxList1.DataTextField = "Name";
        CheckBoxList1.DataBind();
    }
}

0 comments:

Post a Comment