Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8026087
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T23:22:24+00:00 2026-06-04T23:22:24+00:00

I have a group checkbook list which i want to preselect from the database

  • 0

I have a group checkbook list which i want to preselect from the database table. I amusing following code to for the selection of this but it is not working

Data in table is store in following format
example:-

1,2,
1,5,7,
1,2,3,4,

HTML

<asp:checkboxlist id="chkBoxDaysList" runat="server">
 <asp:listitem  runat="server" value="1"  Text="Sunday" />
 <asp:listitem  runat="server" value="2" Text="Monday" />
 <asp:listitem  runat="server" value="3" Text="Tuesday" />
 <asp:listitem  runat="server" value="4" Text="Wednesday" />
 <asp:listitem  runat="server" value="5" Text="Thrusday" />
 <asp:listitem  runat="server" value="6" Text="Friday" />
 <asp:listitem  runat="server" value="7" Text="Saturday" />
</asp:checkboxlist>

C# Code to preselect checkbox based on data saved previously

public void getSelectedDays()
{
IDataReader dr;

String strSqlDays = "SELECT * FROM EventCalender WHERE rowID = 6";
DataSet ds = new DataSet();
ds = DataProvider.Connect_Select(strSqlDays);
dr = ds.Tables[0].CreateDataReader();

string[] s = new string[50];
while (dr.Read())
{
    s = dr["EventDays"].ToString().Split(',');

}
int length = s.Length;
for (int i = 0; i <= s.Length - 1; i++)
{
    string cntry = s[i];
    for (int j = 0; j <= chkBoxDaysList.Items.Count - 1; j++)
    {
        if (chkBoxDaysList.Items[j].Text == s[i])
        {
            chkBoxDaysList.Items[j].Selected = true;
            break;
        }
    }
}

}

Right now code doesn’t generate any error but doesn’t select any checkbox also

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T23:22:25+00:00Added an answer on June 4, 2026 at 11:22 pm

    You are checking text of checkbox with value from DB. Please check value of the checkboxlist with value from DB record.Corrected code is shown below–>

     if (chkBoxDaysList.Items[j].Value == s[i])
            {
                chkBoxDaysList.Items[j].Selected = true;
                break;
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code for an expandable list, I want to have a checkbox
I have a list of checkboxes, but I can not make multi selection from
i have database table with few text fields which i use to filter data
I have contact list which contains (checkbox,firstname,lastname,phone). I am creating this list using html
I have a Table with checkboxes. I want to change the selection of the
I have a group of three radio buttons. Depending on which radio button is
I have a group of radio buttons on my page like this: ALL (x)
I have a group name which contains special characters. CN=IN&T DC Gebnn/Dohn,OU=ABGroups,OU=Hammers,DC=MyCompany,DC=int I am
I want to have a group of radiobuttons that are inactive until a checkbox
Here is my table setup: employee: Employee information, name, address, etc... group: List of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.