Click here to Skip to main content
15,914,221 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
DataTable dtMeetingDetail = objMeetingBAL.GetMeetingForId("GetMeetingDetailsForID", MeetingId);
            for (int i = 0;i<dtmeetingdetail.rows.count;>            {

                code = dtMeetingDetail.Rows[i]["EmployeeCode"].ToString();
                name = dtMeetingDetail.Rows[i]["EmployeeName"].ToString();
                string emailid = dtMeetingDetail.Rows[i]["EmailId"].ToString();
                Session["emailid"] = emailid;

                items.Value = code + '_' + name;
                chkBxToInvite.Items.Add(items);
                items.Selected = true;
            }


dtMeetingDetails.Rows.Count=3;
i=1; name=a;
i=2;name=b;
i=3; name=c;

but the chkBxToInvite(checkboxlist ID) gets 3 count and displays as c,c,c. Couldn't able to get a,b,c(in checkbox)

Is there any solution to solve this problem....
Posted
Updated 20-Oct-13 21:34pm
v4
Comments
Harshil_Raval 21-Oct-13 3:36am    
hi,
items.Value = code + '_' + name;
what is items here? also you have not specified display text value for this.
Timberbird 21-Oct-13 3:38am    
Looks like you are not creating items object in the cycle, instead you add THE SAME object three times. Instead try creating new object (items = new [whatever object it is]) into for loop
JoCodes 21-Oct-13 3:51am    
Yes , I agree with you

Try:
C#
DataTable dtMeetingDetail = objMeetingBAL.GetMeetingForId("GetMeetingDetailsForID", MeetingId);
for (int i = 0;i<dtmeetingdetail.rows.count;>            
{
    ListItem li = new ListItem();
    code = dtMeetingDetail.Rows[i]["EmployeeCode"].ToString();
    name = dtMeetingDetail.Rows[i]["EmployeeName"].ToString();
    string emailid = dtMeetingDetail.Rows[i]["EmailId"].ToString();
    Session["emailid"] = emailid;
    li.Value = code + '_' + name;
    li.Text = code + '_' + name;//can be your choice.
    chkBxToInvite.Items.Add(li);
    items.Selected = true;//should come outside the for loop.
}
 
Share this answer
 
DataTable dtMeetingDetail = objMeetingBAL.GetMeetingForId("GetMeetingDetailsForID", MeetingId);
for (int i = 0;i<dtmeetingdetail.rows.count;i++)>
{
ListItem li = new ListItem();
code = dtMeetingDetail.Rows[i]["EmployeeCode"].ToString();
name = dtMeetingDetail.Rows[i]["EmployeeName"].ToString();
string emailid = dtMeetingDetail.Rows[i]["EmailId"].ToString();
Session["emailid"] = emailid;
li.Value = code + '_' + name;
//Add ur text item for the visibilty in the checkboxlist
li.Text = name;
li.Selected = true; //this ll checked all the items else u can check the only select items based on ur choice.
chkBxToInvite.Items.Add(li);
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900