Forms Data Controls :: Gridview - Save Selected Values And Checked Boxes In Database

Feb 2, 2010

I have a gridview and users would select some records and would click on the submit button and i will be saving those records into database using a stored proc.... now .... just below the gridview and above the submit button there are few checkboxes by default they wud be checked. How would i save the selected values and the checked boxes in database i wrote the stored proc for the gridview but how would i save the checked checkboxes into the same table.

For i As Integer = 0 To gvSelectScreen.Rows.Count - 1
Dim chkTemp As CheckBox = TryCast(gvSelectScreen.Rows(i).FindControl("cbStatus"), CheckBox)
If chkTemp.Checked Then
ContractNumber = gvSelectScreen.Rows(i).Cells(0).Text
ClientProgramNumber = gvSelectScreen.Rows(i).Cells(1).Text
ClientProgramName = gvSelectScreen.Rows(i).Cells(2).Text
StartDate = CType(gvSelectScreen.Rows(i).FindControl("txtStartDate"), TextBox).Text
EndDate = gvSelectScreen.Rows(i).Cells(5).Text
Dim connStr As String = ConfigurationManager.ConnectionStrings("MainConnectionString").ConnectionString
Dim myCon As New SqlConnection(connStr)
Dim cmd As New SqlCommand("usp_ParametersFromGrid")
Dim dt As New DataTable
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.Add("@ContractNumber", SqlDbType.VarChar, 22).Value = ContractNumber.ToString()
cmd.Parameters.Add("@ClientProgramNumber", SqlDbType.VarChar, 22).Value = ClientProgramNumber.ToString()
cmd.Parameters.Add("@ClientProgramName", SqlDbType.VarChar, 100).Value = ClientProgramName.ToString()
cmd.Parameters.Add("@StartDate", SqlDbType.VarChar, 20).Value = StartDate.ToString()
cmd.Parameters.Add("@EndDate", SqlDbType.VarChar, 20).Value = EndDate.ToString()
cmd.Parameters.Add("@RequestID", SqlDbType.VarChar, 50).Value = RequestID.ToString()
cmd.Connection = myCon
myCon.Open()
cmd.ExecuteNonQuery()
myCon.Close()
End If

Now above the submit button as i said, there are few checkboxes and they are checked by default...how would i save the selected item (in the gridview and the checked checkbox values in the same row in the database(sql server)

View 5 Replies


Similar Messages:

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"
PageSize="100">
<ClientSideEvents OnClientSelect="FunMonthList" />
<ScrollingSettings ScrollHeight="400px" />

[Code] .....

View 1 Replies

Data Controls :: Save Checked Rows From GridView Control To Database?

Oct 17, 2012

I have check box field in grid view and I want to save checked row in sql server 2005.how i can save.

View 1 Replies

Data Controls :: Save CheckBoxList Checked (Selected) Text And Value To XML File

Apr 2, 2013

I had few checkbox in a checkboxlist ,On selecting the checkbox I need to create a XML file with the selected checkbox values. How to create the xml file??

View 1 Replies

Data Controls :: How To Save Selected Value In Database From Dropdownlist In GridView

Jun 16, 2015

Came accros your article "How to populate DropDownList in GridView in ASP.Net" 

[URL] How-to-populate-DropDownList-in-GridView-in-ASPNet.aspx.  Was able to duplicate your code w/o any problem.  Works. Noticed that the values selected from the DropDownList are not automatically saved in database.

Question: is it possible just by selecting an item from DropDownList and then moving to another row within GridView save a selected value?  I mean without using edit/update/cancel buttons but just by selecting an item from the DropDownList.

View 1 Replies

Data Controls :: How To Find Checked ListBox Selected Values In Windows Forms Application

May 16, 2013

I Have bind the

 CheckedListBox1.DataSource=ds.Table[0];
CheckedListBox1.DisplayMember="Name";
CheckedListBox1.ValueMember="ID";  [intelligence Not Shown in VS But Its working fine for me].

now i want To Find out The Selected Item value in checkedListBox.

View 1 Replies

Data Controls :: How To Save GridView Row Values On By One To Database

May 7, 2015

I want to add the text box values to grid one by one and next i want to submit all grid values for insert.

View 1 Replies

Forms Data Controls :: Editing A GridView, Dropdown Boxes Do Not Show The Selected Value?

Jul 13, 2010

My dropdown boxes in my GridView just show the top item in the list when I select edit.

[Code]....

Do I need to do something in the CS file to make these show the selected value when you hit edit?

View 6 Replies

Web Forms :: Looping Thru CheckboxList To Get Selected Values And Save To Database?

Feb 21, 2011

I am fairly new to ASP.NET C#, I have a vehicle table which stores basic info about the vehicle, then a vehicle options table that stores the options available on the table.

I have a checkboxlist control on my form and I am populating the list items from the database. I am trying to loop thru the items to determine which ones the user has selected. After determining which ones are selected I need to add rows for each item selected to the vehicle options table.

[Code]....

[Code]....

View 3 Replies

Forms Data Controls :: How To Display Values In Text Boxes When Clicked On Any Row In Gridview

Dec 31, 2010

I have a gridview in my aspx form. I have used template column & in that created a table. In the table of the Item template , I am displaying some fields. My requirement is that when I click on any row, the correspoding data should be placed in proper text boxes. Each row in itemtemplate has a unique id called UserId.

View 9 Replies

Forms Data Controls :: Getting Checked Values From Different Pages Of A Gridview?

Dec 10, 2010

I have a gridview with paging enabled.How can i get the entire checked checkbox values s that i can save it into to a Table.Ie, if i havetwo checkbox checked in page1,three in page Two and two in page three etc.etc. i should get the entire values of a checkbox in a variable so that i can save it into a Table.

View 1 Replies

C# - Using A Few Text Boxes To Display And Save Data To Database?

Feb 11, 2011

Let's say I have a db table like so:Then I have a product edit form that has 3 textboxes in which the user can save up to 3 different notes for a specific product. What is the best way to handle populating and then saving the data? If I use the code below to display it, how do I save it, as the textbox doesn't know the id of the note is.

[code]...

View 1 Replies

Data Controls :: Save CheckBox Selected Values To Cookies?

Mar 26, 2016

I have 3 checkbox and one button in default.aspx page I want when users select these checkboxs and click on button it saves this checkboxs values in cookie...

 I wrote below code:

protected void Imgorder_Click(object sender, ImageClickEventArgs e)
{
HttpCookie order = new HttpCookie("order");
if (CheckBox1.Checked)
{
order.Value = CheckBox1.Text;
}
}
}

is it correct? and if it is correct I wrote it just for 1 checkbox how I can write for 3 checkboxs that if users select them  it saves valuse in cookie...

How I can do it?

View 1 Replies

Forms Data Controls :: Gridview Paging, Keeping Checked Values Of Checkbox?

Mar 29, 2010

I got a list of customers That I'm gone show in the gridview. I have added a checkbox infront of every customer so i can select what customers gone be used and passed to the next method. With a little bit of strugle I almost got everything working now except for this thing with keeping the values of checked customers when I page to the next page (2,3,4,5 ect).

View 1 Replies

Data Controls :: Save Selected Items Of ListBox To Database In Windows Forms Application

Mar 19, 2013

i am making use of two listboxes. the data from one listbox is transfered to other listbox on button click, bt teh the data which is selected must be added to the table in the sql server. but it is not storing values it is throwing execption... 

private void InsertRecords(StringCollection sc)
{
SqlConnection conn = new SqlConnection("Data Source=ABCD;Integrated Security=True");
StringBuilder sb = new StringBuilder(string.Empty);

[Code].....

View 1 Replies

Data Controls :: Print Only CheckBox Checked (Selected) Records Of GridView

Jul 11, 2013

In the Asp.Net Gridview, I am having a checkbox in each and every row for Printing.

I read and test this code found in this link: [URL]

and works really nice, but I would like to use each checked select row for printing instead of clicking "print" each time I print the row.  If I want to print selected checkboxes row, I want to see a window open for printing the checkboxes rows I selected in the gridview.

I also tried this link: [URL]

but doesn't display a new window for printing.

View 1 Replies

Data Controls :: How To Pass CheckBox Checked (selected) Rows Of GridView From One Page To Another

Mar 5, 2014

I want to know how to select only one checkbox and all other will get disabled and when unchecked all will be enabled inside a gridview.

View 1 Replies

Data Controls :: Transfer Selected (checked) Rows From One GridView To Another Using JavaScript And JQuery

May 7, 2015

I want to transfer gridview record to another gridview. Actually I have placed a checkbox column in 1st gridview. Now what I want that when i select the checkbox of any row the related row transfer to 2nd gridview and when I deselect it that row it returns to its previous position in 1st gridview. All these things I want to do using Javascript.

View 1 Replies

Data Controls :: Display Checked (Selected) CheckBox Rows (data) Of GridView In Label

May 7, 2015

in my project i have a gridview gv with 5 rows with check boxes(templatefield).. and 1 label.. my problem is when i check 1st row the row value display in label, if i select 1st row & 2nd row checked the two values display in same label with comma seperation, if i uncheck 2nd row, the row value remove from label and only 1st row will be display..if i select all rows all values are display in label with comma seperation.

View 1 Replies

Forms Data Controls :: Show Checked Checkboxes In Gridview From Database

Mar 4, 2010

I have situation where I have to show checked CheckBox in a GridView. I have three tables

1) Menu Items ( Fields: menuID, menuName, menuLink, .....)
2) User Types (Fields: userTypeID, userTypeName, ...)
3) User Menus (Field: menuID, userTypeID )

I have a screen to add new Menu Items where I am showing a Grid That has two columns

1) CheckBox and
2) User Type

I have to check CheckBox in order to Link that User Type with the Menu Itme. I am done with Add Screen. Here is the Code:

(aspx)
<asp:GridView
ID="gridView_UserTypes"
runat="server"
AutoGenerateColumns="False"
DataKeyNames="userTypeID"
Width="60%"
EmptyDataText="">
<HeaderStyle
CssClass="gridHeader"
Wrap="false"
/>
<AlternatingRowStyle
CssClass="gridAlturnateRow"
/>
<RowStyle
CssClass="gridRow"
/>
<Columns>
<asp:CheckBoxField
DataField="userTypeChecked"
HeaderText="Select"
ReadOnly="false"
Visible="true"
/>
<asp:TemplateField
HeaderText="Select">
<ItemTemplate>
<asp:CheckBox
ID="userTypeSelector"
runat="server"
/>
</ItemTemplate>
<ItemStyle
HorizontalAlign="Center"></ItemStyle>
</asp:TemplateField>
<asp:BoundField
ItemStyle-HorizontalAlign="Left"
DataField="userTypeName"
HeaderText="User Types"
HeaderStyle-Wrap="false"
ReadOnly="True"
SortExpression="userTypeID">
<ItemStyle
HorizontalAlign="Left"></ItemStyle>
</asp:BoundField>
</Columns>
</asp:GridView>
(Code Behind)
foreach (GridViewRow row in gridView_UserTypes.Rows)
{
// Access the CheckBox
CheckBox cb = (CheckBox)row.FindControl("userTypeSelector");
if (cb != null && cb.Checked)
{
// First, get the UserTypeID for the selected row
int userTypeID = Convert.ToInt32(gridView_UserTypes.DataKeys[row.RowIndex].Value);
if (selectedUserTypeIDs == "")
{
selectedUserTypeIDs = userTypeID.ToString();
}
else
{
selectedUserTypeIDs = selectedUserTypeIDs + "," + userTypeID.ToString();
}
userTypeCount++;
}
}

Now I am passing selectedUserTypeIDs along with other details to my Stored Procedure and adding those UserTypes for newly Added menu. It works fine for me. Now I want to show checked CheckBox in Edit Mode.

View 2 Replies

Data Controls :: Save Insert DropDownList Selected Value To Database?

Jan 20, 2014

Based on  below SQL code i would like to control the data insert.

Example If select type is 'DM', then only insert into the WM table. 

string InserttoWM = ConfigurationManager.ConnectionStrings["CIMProRPT01testserverConnectionString"].ConnectionString;
using (SqlConnection Insertcn = new SqlConnection(InserttoWM))
{

[Code].....

View 1 Replies

Forms Data Controls :: Checking Database Value And Checkbox.checked=true In Gridview?

Apr 30, 2010

i have code to update multiple rows in a gridview. What I want is that if the row value is = 1 in the database then the row is checked otherwise it's not. I've put some pseudo code in below to illustrate what I want to achieve.

[code].....

View 3 Replies

MVC :: Retrieve The Selected Values Of The Check Boxes

Aug 7, 2010

I want to show the checkboxes dnamically.

I could show this but i want to retrieve the selected values of the check boxes.

View 6 Replies

Data Controls :: Insert (Save) Selected TreeView Nodes To Database

Nov 22, 2015

<div>
<asp:TreeView ID="TreeView1" runat="server" ExpandDepth="0" ShowLines="true"
OnSelectedNodeChanged="TreeView1_SelectedNodeChanged">

<HoverNodeStyle Font-Underline="True" ForeColor="#6666AA" />
<NodeStyle Font-Names="Tahoma" Font-Size="8pt" ForeColor="Black" HorizontalPadding="2px"
NodeSpacing="0px" VerticalPadding="2px"></NodeStyle>

[CODE]...

View 1 Replies

Forms Data Controls :: Save Values In Editable Gridview?

Feb 18, 2010

I have an editable gridview with blank cells. User enters some numeric data in cells and also user can clicks a button to add new row to gridview. My problem is that, as soon as button click event is fired, the page refreshes & the gridview becomes empty. Can anybody tell me, how can I save values in gridview until the user saves all changes to the server in the end

View 3 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved