473,394 Members | 1,750 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

CheckedBoxList check based on DB value

I'm currently using a CheckedBoxlist which is bound to a database
datasource using SqlDataReader, so far so good, the lists are
displaying correctly.

However I cannot figure how - or even if? - you can also dynamically
check the "checked" staus of the items in the list based on a bit
column in the datasource. Am i going the wrong way about this, is there
something else I could use? (aside from this I'm a little bit unhappy
about the fact that the checkedboxlist control renders in an
unnecessary table, so an alternative way of doing this that doesn't
invlove tables would be welcomed)
Codebehind
private void getListContent()
{
string sp="sp_selectListContents";
string ConnStr =(connectionInfo);
SqlConnection mySqlCon = new SqlConnection(ConnStr);
mySqlCon.Open();
SqlCommand MySqlCmd = new SqlCommand(sp,mySqlCon);
MySqlCmd.CommandType = CommandType.StoredProcedure;
SqlParameter MySqlParam1 = new SqlParameter("@listid",
SqlDbType.VarChar);
MySqlParam1.Value = Request.QueryString["id"];
MySqlCmd.Parameters.Add(MySqlParam1);
SqlDataReader mySqlRead = MySqlCmd.ExecuteReader();
CheckBoxList1.DataSource = mySqlRead;
CheckBoxList1.DataBind();
mySqlCon.Close();
}

aspx page
<asp:checkboxlist id="CheckBoxList1" runat="server"
DataTextField="details" RepeatColumns="1"></asp:checkboxlist>

Thanks for any help
Charlie.

Nov 17 '05 #1
0 1670

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: LRW | last post by:
I have no idea if this is more a PHP question or Javascript question, because my problem hinges equally on both. I have a PHP script that queries a database and creates a list of rows for each...
20
by: | last post by:
If I need to check if a certain value does exist in a field, and return either "yes" or "not" which query would be the most effestive?
2
by: Travis.Box | last post by:
I have an MS Access userform with 16 Check Boxes. Each of the checkboxes has a different option value, which coincides with the Check Box name (eg. cb01.OptionValue = 1). At the bottom of the...
1
by: Neal | last post by:
HI all, I have an issue with check box in datagrid. I would like it to check and uncheck based on a database value of NULL or a Date Value. If there is a date value for that column then check...
3
by: Imran Aziz | last post by:
Hello All, I display a list of entries with a checkbox against them using a repeater control bound to a database table. Based on the value of database table I want to either show the checkbox for...
1
by: sianan | last post by:
I tried to use the following example, to add a checkbox column to a DataGrid in an ASP.NET application: http://www.codeproject.com/aspnet/datagridcheckbox.asp For some reason, I simply CAN'T get...
9
by: Ecohouse | last post by:
I have a main form with two subforms. The first subform has the child link to the main form identity key. subform1 - Master Field: SK Child Field: TrainingMasterSK The second subform has a...
13
by: nishit.gupta | last post by:
Is their any fuction available in C++ that can determine that a string contains a numeric value. The value cabn be in hex, int, float. i.e. "1256" , "123.566" , "0xffff" Thnx
2
by: jbaranski | last post by:
I have spent several days attempting to accomplish a certain task but am truly no closer than I was near the beginning. i need to return a single value based on an employees payment option;...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.