Hi Lakshmi,
Maybe, you can add this code in your Page_Load function.
I wrote them using c#:
if(!this.IsPostBack)
{
initial();
}
private void initial()// you can replace the following code to your own code
{
string query="select * from box";
conn=new SqlConnection(strConn);
conn.Open();
System.Data.SqlClient.SqlDataAdapter ad=new SqlDataAdapter(query,conn);
ds=new DataSet ();
ad.Fill(ds);
System.Data.DataView dw=new DataView(ds.Tables[0]);
CheckBoxList1.DataSource =dw;
CheckBoxList1.DataBind();
conn.Close();
for (int i=0; i<CheckBoxList1.Items.Count; i++)
{
if(CheckBoxList1.Items[i].Value =="True")
CheckBoxList1.Items[i].Selected=true;
}
}
Then, where you click button or set autopostback option, the CheckBoxList
will not be initialized again.
Regards,
wl (Sjtu)
"Lakshmi" <la*****@ayrdata.com> wrote in message
news:eE**************@TK2MSFTNGP12.phx.gbl...
Hello,
I am using Visual Studio .Net and am new to web development. I have added
a CheckBoxlist to my web form (.aspx) and am populating the checkboxlist
from a table in the database and am selecting 4 options (as default) in the
Page_load event of the form. Now when the user selects more options or
deselects some options I save it and draw some graphs on another page.
The problem is the user selected options are not saved and I see only the
default options that the page had initially. The auto postback when set
to true just resets my page with the 4 default options. How can I trap the
user selected options? Some example code would be useful.
Thanks heaps,
Lakshmi