DataSource Controls :: Writing Multiple Gridview Checkbox Values To Database

Jun 11, 2010

I have a checkbox column in a Gridview that I would like to use to insert the value of one cell in the row into an access database. There will be a maximun of five cells allowed to be selected so there can be one value written to one field in the database up to the maximum of the five fields. The access database has five columns: Selection1 ,Selection2, Selection3 ,Selection4 and Selection5

When the checkbox is checked, the value of one cell (PliD) should be written to each field in the database. Ie: checkbox in row 1 should write PliD value to Selection1, checkbox in row 2 should write PliD value to Selection2, checkbox in row 3 should write PliD value to Selection3 and on depending on which checkbox has been checked. I am not sure how to get the value of the checkbox and write it into the corresponding fields in the database.


View 4 Replies

Similar Messages:

Data Controls :: Insert Values Of Multiple CheckBox Values To Database

May 7, 2015

i showed two column (Electronics,Photoshop) but i have six. i want to update their checked or unchecked condition in database (0,1) how do i do?

<asp:CheckBox ID="CheckBox1" runat="server" Text="Electronics" />
<asp:CheckBox ID="CheckBox2" runat="server" Text="Photoshop" />
<asp:CheckBox ID="CheckBox3" runat="server" Text="VideoEditing" />
<asp:CheckBox ID="CheckBox4" runat="server" Text="Gaming" />
<asp:CheckBox ID="CheckBox5" runat="server" Text="Coding" />
<asp:CheckBox ID="CheckBox6" runat="server" Text="Miscellaneous" />

View 1 Replies

Forms Data Controls :: Writing Values Backing Into The Database From The Gridview?

Jun 3, 2010

i just cannot work this out... i have a gridview and when a user clicks on a row the checkbox unchecks itself... when the user clicks the row a sqldatasource.update is called from the selectedindexchanged event, problem is when it writes back to the database it writes back every checkbox as unchecked, i want just the row that's selected...

what i can't work out is i've tried putting a where clause in the sqlcommand which is something like where primarykeyID = gridview1.selectedvalue... now it won't write anything back to the database...!!!
... once i take out the where clause, it writes back to every row..!!

View 9 Replies

DataSource Controls :: Submitting Checkbox Values To Database?

Nov 17, 2010

I am working on a page where the user first selects a state from a drop down, then a city from a checkbox list (eventually able to select multiple cities, but have to figure out how to do one first). The checkbox list is dependent upon the state selected. I would like the selected value of the checkbox to be submitted into the ListingLocation table of the database. In the code I have written I have included a label that displays the id value of the selected box when submitted just to make sure that the checkbox is providing the correct value. For some reason when I select a state and then check a city and click submit, no value is written into the database. The label text changes to the number I want entered into the database, so it is generating the correct number, but not submitting. I have included my code below.

<script runat="server">

View 3 Replies

Forms Data Controls :: Checkbox Values In Multiple Gridview's

Dec 7, 2010

I have a form with three Gridview's. ie. GridView1,GridView2,GridView3.Each gridview contains two templatefield and a boundfield.The first templatefield is a checkbox field and the second one is a labeltemplate with databinding to field "Usr_Id" and the third field is for Name.I have enabled paging for all the three girdview's and different data's are populated on can i maintain the checkbox status while paging for all the three gridview', when i check checkboxes in two pages in gridview1 and checked three pages in gridview2 and so on,i should get the check state of all the gridview checkboxes maintained.I know to maintain the checkstate for a single gridview but when i am checking the pages in second gridview ,the checkbox values of some pages of gridview1 is lost

View 5 Replies

Web Forms :: Store Multiple CheckBox Values In Database

Dec 8, 2012

how to store the 'multiple check box ' record in a database in a single column .. example like "hobbies" for this we have to select multiple check boxes

View 1 Replies

Insert Multiple Checkbox List Values Into Database In Single Column Using C#?

Aug 4, 2010

i use this to select one checkbox to isselected column how i convert this to multi checkboxlist to single column i use many ways more than 3 days without success

private void BindCheckBoxList()
DataTable dt = new DataTable();
SqlConnection connection = new SqlConnection(GetConnectionString());
string sqlStatement = "SELECT * FROM boby";
SqlCommand sqlCmd = new SqlCommand(sqlStatement, connection);
SqlDataAdapter sqlDa = new SqlDataAdapter(sqlCmd);
if (dt.Rows.Count > 0)
CheckBoxList1.RepeatColumns = 4; // set the number of columns in the CheckBoxList
CheckBoxList1.DataSource = dt;
CheckBoxList1.DataTextField = "Name"; // the items to be displayed in the list items
CheckBoxList1.DataValueField = "Name"; // the id of the items displayed
//Setting the Selected Items in the ChecBoxList based from the value in the database
//to do this, lets iterate to each items in the list
for (int i = 0; i < dt.Rows.Count; i++)
if (!string.IsNullOrEmpty(dt.Rows[i]["IsSelected"].ToString()))
CheckBoxList1.Items[i].Selected = Convert.ToBoolean(dt.Rows[i]["IsSelected"]);
catch (System.Data.SqlClient.SqlException ex)
string msg = "Fetch Error:";
msg += ex.Message;
throw new Exception(msg);
private void Update(string name, bool isSelected)
SqlConnection connection = new SqlConnection(GetConnectionString());
SqlCommand cmd;
string sqlStatement = string.Empty;
sqlStatement = "UPDATE handymen SET IsSelected = @IsSelected WHERE Name = @BizName";
cmd = new SqlCommand(sqlStatement, connection);
cmd.Parameters.AddWithValue("@Name", name);
cmd.Parameters.AddWithValue("@IsSelected", isSelected);
cmd.CommandType = CommandType.Text;
catch (System.Data.SqlClient.SqlException ex)
string msg = "Insert/Update error";
msg += ex.Message;
throw new Exception(msg);
protected void Page_Load(object sender, EventArgs e)
if (!Page.IsPostBack)
protected void Button1_Click(object sender, EventArgs e)
string str = string.Empty;
for (int i = 0; i < CheckBoxList1.Items.Count; i++)
if (CheckBoxList1.Items[i].Selected)
str = CheckBoxList1.Items[i].Text;
Update(str, CheckBoxList1.Items[i].Selected);
//ReBind the List to retain the selected items on postbacks

View 3 Replies

Data Controls :: Save Checked Checkbox Values Into Database Which Is Inside GridView

Dec 23, 2015

I have a gridview inside which there are 4-5 checkboxes. In that gridview, I have 10 rows too. So, Now what i want is.

IF I check, 2 checkboxes and don't check remaining checkboxes. how to save the value of the checked checkboxes value as Y and unchecked checkboxes value as N into the database.

Below is the HTML of the checkboxes here:-

 <cc2:Grid ID="GrdRights" runat="server" FolderStyle="../Styles/Grid/style_12"
AllowSorting="False" AutoGenerateColumns="False" AllowColumnResizing="true" AllowAddingRecords="false"
AllowMultiRecordSelection="true" OnRowDataBound="GrdRights_RowDataBound" ViewStateMode="Enabled"
<ClientSideEvents OnClientSelect="FunMonthList" />
<ScrollingSettings ScrollHeight="400px" />

[Code] .....

View 1 Replies

Forms Data Controls :: Check Box In Gridview - Checkbox Are Checkd If Database Values Are Match

May 15, 2010

i got my checkbox control in each row.actually my problem is i bound checkbox in a gridviw and i need those checkbox are checkd if database values are match.i do it like below


but problem is only one checkbox is page_Load i bind gridviw in ROwDatabound event i check Duecode in another i need only matching checkbox should be checked.

View 4 Replies

DataSource Controls :: Writing Data To Database In One Go?

Feb 9, 2010

I was just wondering that when we insert some datainto database we can use the following method.

create a sql datasourse ,
set the conection string,
set the insert comand type,
set insert parameters,
and Set the SQL Statement like
sqldatasource.insertStatement="insert into tablename(field1, field2) values(@parameter1, @parameter2)";

and then call the datasourse insert() function,
this method is usually used for single line insertion at the end of the DB.

Now I am a starter in c#,

I want to know that if There is a way that I have lots of data like some XML file that have the same table structure as the SQL database table
and I want to write that data to the database, HOw to do it Properly,

I can Still achieve the required results by iterating through XML datarows and for each row conecting to db and inserting and then disconecting dfrom the db,

But I want to know that if there is a way to do it in one go meaning I have to conect to database only one time,

Note: I already have some data in my SQL table, there are three fields(ID Name and Nickname) the ID(primary key) is INT type and auto incremented, the name and nickname are strigns.
the xml file has the structure


View 3 Replies

DataSource Controls :: Putting Multiple Select Values Into A Gridview From Using Data Reader

May 20, 2010

So far i've populated my grid view with my roomID. however using data reader I don't seem to be able to get more than one column to auto generate even though i'm now looking for three values : SELECT tt_roomEquip.roomID, tt_room.roomCapacity, tt_equip.equipTitle is my select bit of the sql, though it's only putting roomID into my grid view.

View 1 Replies

DataSource Controls :: Writing Records To Access Database

Jun 4, 2010

I am creating an insert statement in my c# code to insert records to an access database table. I am getting the error copied below using c# code. When I copy the generated insert statement from the console and run this on my access database, it succesfully appends a record in the table.Insert statement generated:

insert into [Pet Fish-log 2010] ([Specimen Type], Year, [Lab Number], [Last Name], [First Name], [Middle Initial], Gender, [Date of Birth], [Collection Date], [Date Received], Client, [Tissue Type], [Block Number],

View 3 Replies

Web Forms :: Getting Values Of A Form Contains MULTIPLE CheckBox Controls

Jan 8, 2010

can i have the code for getting the values including Images & Data associated with Checkbox control which is checked on submited.i'm using table,in which i have images along with values of measurements.if i'm checking the checkbox means i need to get the value of that particular images and i need to send it to an eamil i need a code for getting values of the image. if any one provide a code for this either for normal tables or ASP tables.

<asp:CheckBox ID="chkbx12" OnCheckedChanged="chkLayout_CheckedChanged" Checked="true" AutoPostBack="true" runat="server" Text="Select" Font-Names="Arial" />

likewise i'm using 12 checkbox in a normal table(i.e <td> ).end of the form,there will be a button which should get verfy the checkbox's and set the correct value.

Sub Button3_Click(ByVal sender
As Object,
ByVal e As System.EventArgs)
Handles Button3.Click
'Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim s
As String =
"Selected items:<br>"
Dim i
As Int32
For i = 0
To chkbx(i).Count - 1
If chkbx(i).Selected
' List the selected items
s = s & chkbx(i).Text
s = s & "<br>"
End If
Label1.Text = s
End Sub
Sub chkLayout_CheckedChanged(ByVal sender
As Object,
ByVal e As EventArgs)
If chkLayout.Checked =
True Then
chkbx(i).RepeatLayout = RepeatLayout.Table
chkbx(i).RepeatLayout = RepeatLayout.Flow
End If
End Sub

Is this format is correct.i'm fresher and i dont know realy

View 2 Replies

DataSource Controls :: Insert Multiple Records In Database Using Gridview?

May 22, 2010

I have Gridview on my webapplication and it is getting filled with multiple rows . When clicked on Save I want to Insert all rows without calling multiple database hits.

Is there any way I can insert all rows by single db hit?

View 15 Replies

Forms Data Controls :: Updating The Datasource / Mark All The Values In The Binding Column Of Datasource If Checkbox In Headertemplate Is Checked?

Sep 29, 2010

I am creating a custom gridview control which has a custom CheckBoxTemplateField column (deriving from TemplateField class). This template field column has custom Checkboxheadertemplate (implementing ITemplate) and CheckboxItemTemplate (also implementing ITemplate). In InstantiateIn method of both templates (header as well as Item template), I am adding a checkbox control which has Autopostback = true.

My requirement is:
I want to mark all the values in the binding column of datasource if checkbox in headertemplate is checked. I dont want to mark only rows visible on grid. I WANT TO MARK ALL ROWS IN DATASOURCE. I want to do this in _CheckedChanged event of checkbox in header template.

Problem I am facing: When I check/uncheck the checkbox in header, it postbacks. so in OnCheckedChanged event, gridview's datasource is null. Secondly, in any event of gridview, I could access only those rows of datasource for which corresponding rows are visible in gridview through Gridviewrow.DataItem property. But I want to set it for all rows in datasource.

View 5 Replies

Forms Data Controls :: Gathering Multiple Values From A Checkbox List

Dec 3, 2010

I was able to gather a value from a gridview based on a selected checkbox. However, I would like to be able to grab multiple values instead of just one. I tried using a for loop to gather my information and populate labels as a test. However, that caused an error. This is the code I currently have to use.

foreach (GridViewRow gvr in GridView1.Rows)
if (((CheckBox)gvr.FindControl("CheckBox1")).Checked)
lblTest.Text = gvr.Cells[1].Text;

How to gather multiple values and populate other labels? the other labels are labeled accordingly as lblTest2 and lblTest3. I currently am gathering my data from a gridview and only want to pull the StaffID from gvr.Cells[1].text.

View 28 Replies

Forms Data Controls :: Inserting CheckBox List Values Into Database Rows?

Dec 28, 2010

My problem is this "I have all the tools, VS 2005, 2008, 2010. I have every book, I have SQL server 2005 and 2008" I have all the tools, but I do not know what tool or technology to use when starting out learning all this. I juat do not know what book teaches what I need to do for something like below.

Here is my question:

I created an .ASPX webform that is to "Submit" to a SQL 2005 database. I gave this form to my DBA, and he has made up a Data Model. Now I have to figure out how to write the ASP.NET code so it will submit to the DB. My first issue is not knowing this:

1. "How do I loop through my CheckBox List", and then insert the values checked into a "Database Table" (Each Checkbox value MUST be a seperate row in the table, the DBA does not want a seperate column for each checkbox value)

2. The database is using stored procedures

3. My third issue is this: "I do not know "where" to put the "code". If you do resond to this,

Summary: I just need shown the code on how to "loop through" the CheckBox List on my form, and insert those values into a database table as seperate rows.

View 2 Replies

Retrieve Multiple Checkbox Values?

Aug 2, 2010

I have a checkboxlist on a form and need to find out howI go about finding the values of the ones that might be checked .

<asp:CheckBoxList ID="cbSpillCleanUp" runat="server">
<asp:ListItem Value="EmergencyResponse">911/Police/Fire</asp:ListItem>
<asp:ListItem Value="CentralStation">Central Station</asp:ListItem>
<asp:ListItem Value="ERV">Environmental Response Vendor</asp:ListItem>
<asp:ListItem Value="RegAgency">Regulatory Agency</asp:ListItem>
</asp:CheckBoxList><br />

View 2 Replies

Forms Data Controls :: Get Checkbox Values In A Gridview?

Nov 30, 2010

I have a number of checkboxes embedded in a gridview. I would like to give users a dropdownlist based on when certain checkboxes have been selected.

I have tried to accomplish this by adding an onlick event to the checkboxes when they are loaded.


In my javascript i try to get the value that was selected. That worsk okay but when i item is de-selected i am confused about how to determine if there are no more selected rows that satisfy the condition i mentioned above.

Below is the javascript i came up with


Is there a way to get the values on a selected checkbox to determine if it satisfies a certain condition for displaying a dropdownlist?

Also, how can i loop through the checkbox items to make sure the conditions are met in order to display the dropdownlist

View 1 Replies

DataSource Controls :: Checkbox List Items Stored In Database?

Apr 6, 2010

In the user form, the user has a chekboxList, and he can select more than one item.

how can I store those selected items in database, and how then I can retrieve them.
Is it true to make a separate column for each item, and then if selected, then that cloumn will have "1" and "0" for non selected.
Only that idea occurred to my mind, and I think that I can find better it.

View 7 Replies

DataSource Controls :: Multiple Values Into The Same Table?

Feb 6, 2010

I am creating an online employment application, and instead of creating a table with 20 columns for job duties that may or may not receive values, I simply want to create 3 columns

EmployerName (Name of Work history Employer)

I want to create a form on a page with 10 textboxes so the applicant can type in some job duties they had at that job.

Is there a way in C# or SQL to then cycle through and insert the textbox values as separate rows?

View 4 Replies

Data Controls :: Filter GridView Using Multiple Checkbox Lists

Nov 4, 2013

i am stucked in Checkbox Filteration issue... My problem is If first checkbox list is checked and user clicks on second checkbox list then i want to compare both checkboxes and populate result based on both checkboxes. using System;

using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data.SqlClient;


View 1 Replies

DataSource Controls :: Set Up SQL Table Columns To Have Multiple Values?

Mar 9, 2010

Is it possible in to set up an SQL table column to have multiple values? Or would I have to put my values into a new table and link it to the original one?

View 6 Replies

DataSource Controls :: Using Multiple Values In A Parametrized Query?

Aug 13, 2010

SELECT ClientMaster.ClientName,*
FROM ProjectMaster LEFT JOIN ClientMaster
ProjectMaster.RefCode IN (@refcode) AND ProjectMaster.ProjectStatus=@status

@refcode should be able to contain multiple values but how should I pass value to the parameterized query?

I have tried many ways such as @refcode = 'VALUE1','VALUE2', @refcode = VALUE1,VALUE2 but to no avail?

View 3 Replies

Web Forms :: Multiple Checkbox - Retrieve The Values Of Each Item That Is Checked

Dec 8, 2010

I am using a Checkboxlist and want to retrieve the values of each item that is checked.


This is only returning the first value selected: Label1.Text = this.chkCommunicate.Text;

View 10 Replies

Copyrights 2005-15, All rights reserved