.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Post New Web Links

Reading/storing values of checkboxlist in SQL (VB)

Posted By:      Posted Date: September 23, 2010    Points: 0   Category :ASP.Net

Hi there,

I'm trying to store multiple selected checkboxes from a single checkboxlist, but i don't know where to start.. Sealed
Imagine i have three tables: tbl_events, tbl_organisors and tbl_settings and i want to store the organisors of an event.

Each event can have multiple organisors, so each organisor should be added as a single row into tbl_settings.
I know how to bind tbl_organisors to a checkboxlist, but how do i store the results (meaning: add the rows to tbl_settings) ?

tbl_events: Event_ID (PK) and Event_Name
tbl_organisors: User_ID and user_name.
tbl_settings: Settings_ID (PK), Event_ID and User_ID


<asp:CheckBoxList ID="CheckBoxList1" runat="server" DataSourceID="SDS_Organisors"
DataTextField="User_Name" DataValueField="User_ID" RepeatColumns="2">


<asp:SqlDataSource ID="SDS_Organisors" runat="server" 
        ConnectionString="<%$ ConnectionStrings:LocalConnectionString %>"

View Complete Post

More Related Resource Links

reading values from config files in NUnit tests


One of my NUnit tests has to read in some values from config files.  In my main application this process works perfectly well, however when I run the unit test, the code that reads in the values from the config files doesnt read anything in.  Ive tried putting app.config in my unit test project (I even tried web.config) but nothing seems to work.  Are there any special steps involved when reading from config files in an nunit test ?

Reading values from data access component individually



I am trying to pick data from the database through data access layer and use those values in different text boxes on the page.Basically on a click on the form, modal popup is planned to read the database and put the values into different text boxes which can be latter changed/ updated.

 What I am unable to do is accessing those values on the form itself progamatically. I will be thankful for any ideas and help.

My data access component is as follows:




new SqlParameter ("@reg_id", SqlDbType.Int ));"@reg_id"].Value=reg_id;try




Problem getting values next to each other from two separate CheckBoxList controls

Hi, I am using three CheckBoxList controls in ASP.NET Wizard control. CheckBoxList controls: <asp:CheckBoxList ID="cblLondonDates" runat="server" DataSourceID="SqlDataSource1" DataTextField="ShowDate" DataTextFormatString="{0:G}" DataValueField="ShowDate" ForeColor="#333333" CssClass="ShowDateMargin"></asp:CheckBoxList> <asp:CheckBoxList ID="cblSingleL" runat="server" DataSourceID="SqlDataSource2" DataTextField="size8" DataValueField="size8" ForeColor="#333333"> </asp:CheckBoxList> <asp:CheckBoxList ID="cblHalfL" runat="server" DataSourceID="SqlDataSource2" DataTextField="size6" DataValueField="size6" ForeColor="#333333"></asp:CheckBoxList>   cblLondonDates chackboxlist control shows dates generated from SQL table. cblSingleL an cblHalfL show table sizes. On ASP page they come up as following: 12/03/2011(checkboxlist-ID="cblLondonDates")-Single(checkboxlist-ID="cblSingleL") - Half(checkboxlist-ID="cblHalfL") 03/03/2012(checkboxlist-ID="cblLondonDates")-Single(checkboxlist-ID="cblSingleL") - Half(checkboxlist-ID="cblHalfL") 05/10/2010(checkboxlist-ID="cblLo

Error while reading values on postback

I have some problems with trying to read values on a postback.The fields, textboxes and dynamiclly created fields doesn't keep their values or I'm doing something wrong when trying to read the values. I get an error message: System.NullReferenceException was unhandled by user code  Message="Object reference not set to an instance of an object."  Source="App_Web_m-6qot6q"  StackTrace:       at Sikt.RäknaVärden() in C:\Visual Studio 2005\WebSites\Kalibreringscertificat\Sikt.aspx.vb:line 688       at Sikt.Button1_Click(Object sender, EventArgs e) in C:\Visual Studio 2005\WebSites\Kalibreringscertificat\Sikt.aspx.vb:line 892       at System.Web.UI.WebControls.Button.OnClick(EventArgs e)       at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)       at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)       at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)       at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)       at System.Web.UI.Page.ProcessReque

CheckBoxList in UpdatePanel won't change values

Hello all.  I have a CheckBoxList that contains the days of the week.  If I use standard asp.net with AutoPostBack = true, everything works fine.  However, I would like to not have post backs everytime a user selects a day, so I'm trying to get the control to update using Atlas.  Here is the code (note: I put in the asteriks to bypass the filters on this website):  <*atlas:UpdatePanel ID="validDaysUpdatePanel" runat="server" Mode="Always"> <*ContentTemplate> <*asp:CheckBoxList ID="cblValidDays" runat="server" CssClass="inputfields" RepeatDirection="Horizontal" AutoPostBack="True" OnSelectedIndexChanged="cblValidDays_SelectedIndexChanged" > <*asp:ListItem Text="All" Selected="True"><*/asp:ListItem> <*asp:ListItem Text="Sun" Value="1"><*/asp:ListItem> <*asp:ListItem Text="Mon" Value="2"><*/asp:ListItem> <*asp:ListItem Text="Wed" Value="4"><*/asp:ListItem> <*asp:ListItem Text="Thu" Value="5"><*/asp:ListItem> <*asp:ListItem Text="Fri" Value="6"><*/asp:ListItem> <*asp:ListItem Text="Sat" Value="7"><*/asp:ListItem> <*/asp:CheckBoxList> <*/ContentTemplate> <*Triggers> <*atlas:ControlEventTrigger ControlID="cblValidDays" EventName="SelectedIndexChanged" /> <*/Triggers> <*/atlas:Upd

CheckBoxList - save values to SQL

Hi, I have a checkboxlist on a c# page where when a box is checked it saves its value in the following format to a textbox 1,2,3, etc...  String values = ""; for (int i=0; i< cbl.Items.Count; i++) { if(cbl.Items[i].Selected) { values += cbl.Items[i].Value + ","; } } values = values.TrimEnd(','); This works ok however the problem is i want to be able to audit the values i save in the DB. For example i may want to do a count how many times 1 appears or 2 etc.. What is the best way to do this? Thanks 

Storing multiple values in Cookies

I have a page which displays multiple products. Each product has an unique ID. When a user clicks a particular product the description about the product will be displayed in another page. What I want is I have to store the product id's of all recent products visited in a cookie. And I have to show in the same module that these are the products the user visited recently.I tried with cookie, but it stores only a single value(productID).How to store multiple product id's the user visted recently in cookie and how to retrieve it.

Insert checkboxlist selected values into sql table using createuser wizard



I am using CreateUserWizard control where I collect personal information from the user on the first step (ie. name, address, tel, mobile etc) then on the second step I collect information for membership service (ie. user name, password, email etc). When user clicks Create button, information is sent to two different tables in the same database. Everything works fine but one.

In the first step where I collect personal information, I also collect details about Interest which is a CheckBoxList (CheckBoxList is getting values from Interests table: 1-White, 2-Green, 3-Brown, 4-Maroon, 5-Yellow).

What I want to do is, when client selects his itnerest categories and clicks Create button, to send selected values from CheckBoxList into the third table called Categories. I want values to be registered into the CatCode column in Interests table as comma delimited. For example: if client selected "White", "Green" and "Yellow", appropriate values for those interests (such as 1, 3, 5) to be registered under Categories table CatCode column (like: 1,3,5).

Following is my code:

<asp:CreateUserWizard ID="CreateUserWizard1" runat="server" 

Reading values before and after a forward slash....


Hi all,

How can we split values from one column? I have a column in table like "work Experience".

"02/03" Month and Year. I want to split that values and display in saperate labels.

after clicking edit button they are displayed on dropdown list. Similarly i want to do for Annual CTC column.The Split for annual CTC will be Total Sal in Lakhs and In Thousand.

Just want to write split function for that.How can i write and display?

If any one can get the answer plz replay me.

Thanks in advance.

storing values to brigding tables!


hi friends,

assume i have the following table strucutre and relationship to demonstrate M : N relationship:


From fv


The relation is between the roles and the user and their briedgig entity. when i save a new user the form allocated the roles, (and only role_id are passed to tbe backend).

In this, DAL, i have written a method to generate a xml document that of following structure and values:


But in the bridging table UsersUserRoles contain another column called "special notes", XML was generated to store all the ROles of teh saving user, the id values in the xml document will be saved to the UserUserRoles. But since the bridging table has the column SpcialNotes should i also add an element <specialnotes> to the xml docu

Reading in values in text file in a project solution to an array



I have a tab delimited text file that has 6 columns (all integers) and 500 rows (and no column headings) called ProjectData.txt that I have added to my Windows Form Application (c#) (by added I mean I have it in my project solution). 

I have declared an array in my code called ProjectDataArray which has dimensions [500, 6].

I wish to load each column of each row into the array.

All the code I have seen shows how to do this for text files that are not included in the project solution. 

Is this easy to do?

Reading inner node values of xml


I have an xml file in the below format.

<?xml version="1.0" encoding="utf-8"?>
<Control ID="Title" Editable="true" UserControlName="Title.ascx"  Visible="true" Enabled="true" ></Control>
<Control ID="Edit"  Editable="true" UserControlName="Edit.ascx"  Visible="true" Enabled="true"></Control>

I need to loop through each element and get the value.

Using XmlTextReader iam able to do that but  If the tag name is <Control> then i need to get values for ID,Editable,UserControlName,Visible etc.. after that again read node values only  if the node is <Content> it should read all the attribute values for  that <Content>.

Please help me out

Determine node type selected in TreeView and reading property values


I am hoping that someone can help me get past some problems I am having when using the WPF TreeView control.  I have a TreeView that at most can have 3 levels.  The levels are defined as Project, Discipline, Person which would look like the following:

+ Project

    + Discipline

        - Person

My TreeView is bound to a database using two HierarchicalDataTemplate's and then one DataTemplate (the binding is done in the XAML).

What I would like to get is the following information when selecting an item:

  1. Read the selected value (text of the selected node)
  2. Reading Enclosure values and media:thumbnail values


    Hi I've been looking for a solution but I can not get any code that works, I want to read the URL values of the fields <enclosure and <media:thumbnail following you will find the rss feed and the vb code, I think Im missing something, but I dont know where

    <rss version="2.0"
      <title>Content from Margarita</title>
      <pubDate>Fri, 18 Apr 2008 13:13:24 -0800</pubDate>
      <lastBuildDate>Fri, 18 Apr 2008 13:13:24 -0800</lastBuildDate>

Checking Some Values In A CheckBoxList In The Page Load Event.


Hello forum,

I have a checkboxlist (cblTeamMates) with a sqldatasource (sqlTeamMates) that has 3 columns (ID, FullName and Status ).  The datavaluefield and datatextfield for cblTeamMates is "FullName" and the 2 status values possible are "Available" and "Absent".  How do I go about, in the page load event,  checking all  the names (FullName) whose Status is "Available"?

Thank you.

Pass Checkboxlist control multiple selected values to SQL table



I wanted to know if it is possible to pass multiple selected values from Checkboxlist to SQL table so each selections goes into separate row in the table.

I tried it using the following code (to pass ShowDate value) but it enters value only if I make one selection. It gives me an error message if I make two selections and try to pass it to SQL.


string showdate = string.Empty;

foreach (ListItem li in BirmShowDates.Items)
            if (li.Selected)
                showdate += li.Value;


            string sql = "INSERT INTO [BShow] ([Single], [UserId], [ShowDate], [Half]) VALUES (@Single, @UserId, @ShowDate, @Half) SELECT [Single], [UserId],  [ShowDate], [Half] FROM [BShow] WHERE [BShow].[ShowDate] = [BShow].[ShowDate]";

            SqlCommand cmd = new SqlCommand(sql, conn);

cmd.Parameters.AddWithValue("@ShowDate", showdate.ToString());


Thank you.

Modelling\Storing KPI Values


There is a requirement for the DW that we are building warehouse for the business managers to be able to set "targets" for their employees and for various the Contracts that they work on.

A front end application has been built to collect and store this information in a SQL database which we have assumed we would store as a FACT table in our warehouse and then get them turned into KPI's, however now we're a bit stuck with how to implement this

The Employees and the Contracts are stored as seperate Type 2 dimensions and we have a Fact Table which captures the events we are interested in and this obviously stores the corresponding surrogate keys for the Employee and Contract for that particular event/transaction.

However the targets that will be set are really against the dimensions naturalkeys ie the employeeid and contract id rather than the specific version of the dimension

any suggestions or pointers on how to attack this?

many thanks

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend