how to give default selection for checklist on checkbox selected

Posted by Priti2010 under ASP.NET on 8/8/2012 | Points: 10 | Views : 1178 | Status : [Member] | Replies : 4
Please help how can i give default selection to my checklist on checkbox selection
for eg:
<asp:checkbox id="chkbox1" runat= "server"/>

This is my main checkbox an on this selection my checklist value should be default true so that user can see the selection and i can save it as a parameter in my stored procedure
<asp:checkboxlist id="chkoptn" runat="server>
<asp:listitem>1<asp:listitem>
<asp:listitem>2<asp:listitem>
<asp:listitem>3<asp:listitem>
<asp:listitem>4<asp:listitem>
</asp:checkboxlist>

Please let me know how can i do

Thanks & Regards
Priti



Responses

Posted by: Ranjeet_8 on: 8/8/2012 [Member] [MVP] Gold | Points: 25

Up
0
Down
Try this
    

<asp:CheckBoxList ID="chkoptn" runat="server">
<asp:ListItem Selected="True">1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
<asp:ListItem>4</asp:ListItem>
</asp:CheckBoxList>


Priti2010, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Priti2010 on: 8/8/2012 [Member] Starter | Points: 25

Up
0
Down
but it should be on checkbox1 selection, it is showing bydefault checked but it should be on main checkbox selection or else it should be unchecked

Thanks & Regards
Priti

Priti2010, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ranjeet_8 on: 8/8/2012 [Member] [MVP] Gold | Points: 25

Up
0
Down
please explain ur problem in details
or attached ur sample file.

Priti2010, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Priti2010 on: 8/8/2012 [Member] Starter | Points: 25

Up
0
Down
if (chkRecmmdtn.Checked == true)
{
chkno = 2;
//------------------------ LOOP FOR RECOMMENDATIONS ---------------------
int j = 0;
string[] b = new string[4];
for (j = 0; j <= chkOpt2.Items.Count - 1; j++)
{
if (chkOpt2.Items[j].Selected == true)
{
b[j] += chkOpt2.Items[j] + "";
}
}
//InsertTypedata(str1, str1, chkno, b[4]);
SqlParameter[] objPrms = new SqlParameter[7];
//SqlParameter objPrms = new SqlParameter();
objPrms[0] = new SqlParameter("@REG_NEW_ID", SqlDbType.VarChar, 100);
objPrms[0].Value = str1;
objPrms[1] = new SqlParameter("@portfolio_new_id", SqlDbType.VarChar, 100);
objPrms[1].Value = str1;
objPrms[2] = new SqlParameter("@type", SqlDbType.Int);
objPrms[2].Value = chkno;
objPrms[3] = new SqlParameter("@IS_AGM", SqlDbType.Int);
objPrms[3].Value = Convert.ToInt32(b[0]!= null?true:false);
objPrms[4] = new SqlParameter("@IS_EGM", SqlDbType.Int);
objPrms[4].Value = Convert.ToInt32(b[1] != null ? true : false);
objPrms[5] = new SqlParameter("@IS_CCM", SqlDbType.Int);
objPrms[5].Value = Convert.ToInt32(b[2] != null ? true : false);
objPrms[6] = new SqlParameter("@IS_PB", SqlDbType.Int);
objPrms[6].Value = Convert.ToInt32(b[3] != null ? true : false);

ds = SqlHelper.ExecuteDataset(ConnStr, CommandType.StoredProcedure, "USP_INS", objPrms);

This is my code, this is for one checkbox where my checklist values are checked and stored in db. but i m not able to stored all the values in db on 3rd checkbox checked and also user should be able to see that values are checked by default on 3rd checkbox checked,

Thanks & Regards
Priti

Priti2010, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response