Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    ASP.NET


Advertisements:










C# - Insert Selected Rows Value Of Gridview Into Database?


I am Developing Windows Form Application in .Net, I want to insert selected rows value of Gridview into database. First Column of my GridView is Checkbox, when user check one or more checkbox from gridview, i want to insert values of respective rows into Database. In Web application i done this using DataKeyNames property of GridView. Want to know how to do it in Windows Form Application. I am using Visual Studio 2005.


View 2 Replies (Posted: Apr 21 10 at 5:59)

Sponsored Links:

Related Forum Messages For ASP.NET category:
Forms Data Controls :: Insert New Blank Rows In A Gridview And Insert Them In Database Multiple At A Time?
I have grid view in ASP.Net 3.5. I need to add multipleblank rows in a gridview and then have to save them in database. How can I do that in most simplest way?

Posted: Oct 19, 2010 01:48 AM

View 7 Replies!   View Related
Forms Data Controls :: Gridview - Insert Multiple Rows Based On Selected Checkbox
I have a gridview object to which I added

<asp:TemplateField >
<ItemTemplate>
<asp:CheckBox ID="chkCopy"
OnCheckedChanged="chkStatus_OnCheckedChanged"
runat="server" />
</ItemTemplate>
</asp:TemplateField>

Thepage count is set to 10, when the user checks the checkbox(es), I will need to insert those records in atable. How will I know which row was selected? I found an example (untried) that is designed to loop through and insert the necessary records; but it does not address inserting records based on selecting rows via a checkbox. How do I put everything together.

// open connection
mySqlConnection.Open();
//enumerate the items in the list
foreach (SPListItem curItem in curItems)
{
string sql = "INSERT INTO ImportNotifications";
sql += "
(SharepointID,Title,WorkOrderNumber,Status,Department,ClientName,WorkOrderDueDate,CreatedDate,CreatedBy,ModifiedDate,ModifiedBy,Late,LateRe
view,TrueLate,Body)";
sql += " VALUES
(@ID,@Title,@WorkOrderNum,@Status,@Department,@ClientName,@WorkOrderDue,@Created,@Author,@Modified,@Editor,@Late,@LateReview,@TrueLate,@Bod
y)";
mySqlCommand.CommandText = sql;
mySqlCommand.Parameters.Clear();
mySqlCommand.Parameters.Add(new SqlParameter("@ID", SqlDbType.Float)).Value = curItem["ID"];
mySqlCommand.Parameters.Add(new SqlParameter("@Title", SqlDbType.NVarChar, 200)).Value =
curItem["Title"].ToString();
mySqlCommand.Parameters.Add(new SqlParameter("@WorkOrderNum", SqlDbType.NVarChar, 50)).Value =
curItem["Work_x0020_Order_x0020_Number"].ToString();
mySqlCommand.Parameters.Add(new SqlParameter("@Status", SqlDbType.NVarChar, 50)).Value =
curItem["Status"].ToString();
mySqlCommand.Parameters.Add(new SqlParameter("@Department", SqlDbType.NVarChar, 100)).Value =
curItem["Department"].ToString();
mySqlCommand.Parameters.Add(new SqlParameter("@ClientName", SqlDbType.NVarChar, 255)).Value =
curItem["Client_x0020_Name"].ToString();
mySqlCommand.Parameters.Add(new SqlParameter("@WorkOrderDue", SqlDbType.DateTime)).Value =
curItem["Work_x0020_Order_x0020_Due_x0020"];
mySqlCommand.Parameters.Add(new SqlParameter("@Created", SqlDbType.DateTime)).Value = curItem["Created"];
mySqlCommand.Parameters.Add(new SqlParameter("@Author", SqlDbType.NVarChar, 50)).Value =
curItem["Author"].ToString();
mySqlCommand.Parameters.Add(new SqlParameter("@Modified", SqlDbType.DateTime)).Value = curItem["Modified"];
mySqlCommand.Parameters.Add(new SqlParameter("@Editor", SqlDbType.NVarChar, 50)).Value = curItem["Editor"];
mySqlCommand.Parameters.Add(new SqlParameter("@Late", SqlDbType.NVarChar, 50)).Value = curItem["Late"];
mySqlCommand.Parameters.Add(new SqlParameter("@LateReview", SqlDbType.NVarChar, 50)).Value =
curItem["Late_x0020_Review"];
mySqlCommand.Parameters.Add(new SqlParameter("@TrueLate", SqlDbType.NVarChar, 50)).Value = curItem["TrueLate"];
mySqlCommand.Parameters.Add(new SqlParameter("@Body", SqlDbType.NVarChar, -1)).Value =
curItem["Body"].ToString();
// execute the command
mySqlCommand.ExecuteNonQuery();
}
// close the connection
mySqlConnection.Close();

Posted: Aug 11, 2010 07:21 PM

View 4 Replies!   View Related
Forms Data Controls :: Creating Selected Rows In Gridview To Database?
I would like to create those checked/selected rows in gridview to SQL server database with a button click.For example, an user checks 2 rows in the gridview, and clicks on the create button. I would want the selected row/s to be created to the database. How would I go about doing this?

Posted: Jan 19, 2010 07:34 AM

View 4 Replies!   View Related
Forms Data Controls :: Insert All The Rows Of A Gridview To Database On One Button Click
I have a webgridview filled by user input. after filling all the data , I want the user to click on submit button & then all the rows should be saved to database, row by row.

Posted: Nov 17, 2009 05:58 PM

View 5 Replies!   View Related
Forms Data Controls :: Add A TemplateField "Insert Row" Button To Insert 1 Blank Row At Selected Row Using Rows.AddAt?
I have a GridView (BulkEditGridView), that has 10 rows from the datasource. I Add a TemplateField "Insert Row" button to insert 1 blank row at selected row using Rows.AddAt.First time i press "Insert Row", it works as expected, the row inserted at selected row. now i press another "Insert Row", the row is inserted, however the row (in first time inserted) now move to the last row. and so on.

Posted: Mar 24, 2011 07:32 AM

View 7 Replies!   View Related
SQL Server :: Bulk Insert Or Insert Multiple Rows Into Database At A Time?
i need to insert multiple rows at a time into database table(sqlserver) from datatable or gridview. Actually iam looping through the rows of gridview and inserting each row. Is there any method to insert entire table of rows at a time into database table. Both datatable columns and database table coulmns are similar.

Posted: Aug 20, 2010 09:23 AM

View 2 Replies!   View Related
DataSource Controls :: Insert Multiple Rows In One Database Call
I want to insert almost 400 rows in one database call in asp.net. I am using .net 3.5 and sql server 2005. What should be the best possible way for doing that?.

Posted: May 19, 2010 11:01 AM

View 1 Replies!   View Related
How To Select Multiple Items From ListBox And Insert Into Database In Separated Rows
I have 3 tables (users - Project - User_Project ),when create new project ,I want the user to be able to choose1or many users and insert the selections into a table called User_Project .

select users from listbox.

Tables :
users :
user_ID :
User_Name :
Projects:
Project_ID:
Project_Name
User_Project
user_ID :
Project_ID:

Posted: Jan 11, 2009 11:06 AM

View 6 Replies!   View Related
SQL Server :: Insert Large No Of Excel Sheet Rows Into Database Table?
I have an excel sheet that contains around 30,000 rows and 18 colmns. These no of rows and columns may increase in future. I need to read all these records from excel sheet and insert into a table in sql database. For reading the excel book I am using Oledbconnections. The possible solutions I have known as per my knowledge, to insert the data are

1. To insert one record at a time which makes 30,000 database hits. How will this affect the performance?
2. To use liked servers - bu this is not working for me.I do not have database permissions to use linked servers. So, the only option i have is the first one.

Posted: Aug 17, 2010 05:51 AM

View 2 Replies!   View Related
How To Insert A Selected Date On The Calendar Control Into A Sql Database
i am using a gridview and a calendar control . when i select a date in the calendar control , how can i insert it directly into SQL database? i am using ASP.net wit VB.net and a SQL Server database. To bind the gridview , i use dataset objects and table adapters.

Posted: Jan 22, 2009 05:05 AM

View 8 Replies!   View Related
MVC :: Insert Selected Check Box Value And Related Text Box To Database?
I am very new to MVC and I have a Model like this

User :

FirstName : TextBox LastName : TexBox User Commitee : [CheckBox Textbox] [CheckBox Textbox] [CheckBox Textbox]

I store if user is in committee in a separate table.I need to insert selected check box value and related text box to database.How can I achieve this ? Can this be possible with using EditorTemplate ?

Posted: Oct 22, 2010 04:34 PM

View 1 Replies!   View Related
How To Get The Selected Item In Drop Down List And Insert It Into Database
how do i get the selected item in the drop down list and insert it into database (togethi populated the drop down with the values from the tables in database. It is dynamic, not static.i have a button in the gridview called 'add'. so when user clicks on it the row (whatever columns in the row) would be inserted into database. i am doing insertion/create for this.

Posted: Jan 29, 2010 01:23 AM

View 14 Replies!   View Related
JQuery :: How To Pass Id Of Selected Rows In A Gridview To Another Page
here is my code where i want to pass the IMAGE_ID of selected rows onto next page.

public partial class ADMIN_SELECT_IMAGE : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)

[code]...

Posted: Feb 08, 2011 02:36 AM

View 5 Replies!   View Related
C# - Retrieving The Underlying Dataitems Of Selected Gridview Rows?
I have a button on the page and a gridview with checkboxes on the first column. The gridview is bound to a List. On buttonClick, I need to retrieve the underlying bound data item (MyEntity) for each selected row. How can I do this? I can't simply recreate MyEntity based on the gridview columns, because I am not displaying all the fields of MyEntity. I need a way to get a hold of MyEntity based on the key (MyEntityId).

Posted: Oct 29 10 at 22:01

View 2 Replies!   View Related
Visual Studio 2005 - Extract Rows From DataBase - Replace Fields - Insert Into Another Table
I work with Visual studio 2005 and Sql server data base. I extract 1 million rows from a database and I put the rows in a Sql table. With a simple direct extraction, in a few minutes I complete the operation:

Dim cmd As New SqlCommand(query, cnSql)
cmd.ExecuteNonQuery()
cmd.Dispose().

But, if I must select and modify some fields between extraction and introduction, it takes a lot of time!
I work in this way. I extractrows from Dbase, Table1, and I put all into a Collection using dataReader:

Dim cmd As New SqlCommand(query, cnSql)
Dim coll As New Collection
coll.Clear()
Dim dr As SqlDataReader = cmd.ExecuteReader()
I replace some fields with the string "YES".
Dim toRepl As String = ""
If dr.HasRows Then
Do While dr.Read
toRepl = dr(5).ToString
If Len(toRepl) <= 3 Then ToRepl = "YES"
collPrel.Add(dr(0).ToString)
collPrel.Add(dr(1).ToString)
.................. ..............
collPrel.Add(toRepl)
collCount = collCount + 1
Loop
End If
dr.Close()
cmd.Dispose()
Now, I insert all into a SQL Table2:
Dim a As String = "", b As String = "", c As String = "" etc.
For i = 1 To collPrel.Count Step 6
a = collPrel.Item(i).ToString
b = collPrel.Item(i + 1).ToString
.............. ...............
f = collPrel.Item(i + 5).ToString
queryIns = "INSERT INTO Tab (name, adress, etc)
VALUES ('" & a & "', '" & b & "', '" & c & "', etc. )
Dim cmdIns As New SqlCommand(queryIns, cnSql)
cmdIns.CommandTimeout = 600
cmdIns.ExecuteNonQuery()
cmdIns.Dispose()
Next

This way to work goes right but it is necessary a lot of time for completing the operation.

Posted: Mar 08, 2010 10:15 AM

View 1 Replies!   View Related
Web Forms :: Insert 8 Different Selected Values From A CheckBoxList Into 8 Different Columns Of A Database
I am trying to insert 8 different selected values from a CheckBoxList into 8 different columns of a database. As it now, I am only able to concatenate all 8 selections into a single string in one column. But this is not what I want to do. In my DB I have Column1, 2, 3, 4, 5, 6, 7, 8. Is there any way of getting this done?

Posted: Aug 01, 2010 07:50 AM

View 5 Replies!   View Related
Web Forms :: Insert The Selected Values Of A Listbox In Database Through The Linq?
i have to insert the selected values of a listbox in database through the linq. I am doing like this

[Code]....

but it is actly inserting only first selected item.

Posted: Oct 11, 2009 01:58 PM

View 3 Replies!   View Related
Forms Data Controls :: GridView Selected Rows Validation?
I want some solution for my gridview to validated only selected rows.What is the senario:In my gridview there are1templatecolumn - Total Balance -txtTotalBalanceand1 another templatecolumn - Amount Received-txtAmountReceived There are checkboxes I want to compareonly that row which is checked with txtTotalBalance with txtAmountReceived should not be greater than totalbalance.In current code all rows validating compare validator.That I don't want.Please give me solution-If possible then please send me the code also..

Posted: Oct 15, 2010 07:16 AM

View 2 Replies!   View Related
Forms Data Controls :: Get GridView's Selected Rows's Cell Value?
this is my aspx code fro a gridview

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="4" DataKeyNames="SubContract_No" ForeColor="#333333" GridLines="None" OnRowDeleting="GridView1_RowDeleting" Width="900px" ShowFooter="True" OnRowEditing="GridView1_RowEditing"
>

[Code]....

Budget_Line is my Gridview's first column How to get this value

Posted: Dec 30, 2009 06:05 AM

View 5 Replies!   View Related
Forms Data Controls :: Insert Rows In GridView On DataBind?
I have a GridView which is databound to a database table. Let's say each record contains a date and the monetary profit for that day. Now here's the problem. Some dates have no record in the table because the store was closed or it's just so shitty that no profit was made. As a result the gridview looks like the following:

10/01/2009 $200
10/02/2009 $250
10/05/2009 $300
10/07/2009 $210

Obviously if there is no record, no row is inserted into the gridview. Instead, I want the gridview to display the results as follows:

10/01/2009 $200
10/02/2009 $250
10/03/2009 $0
10/04/2009 $0
10/05/2009 $300
10/06/2009 $0
10/07/2009 $210

So in other words, when there is no record, I want a row to be inserted into the gridview with the missing date and $0. How would I acheive this? I'm assuming I'll need to use a DataTable and perhaps do some stuff in the DataBind event of the gridview

Posted: Oct 03, 2009 09:45 PM

View 5 Replies!   View Related
Forms Data Controls :: How To Remove Selected Rows From Gridview And List
I m working on MOSS 2007.My project requirment is to fetch the data from list to gridviewwith check boxes in front of all rows. when we click the checkboxinfront of rows then that rows will be move to another gridview & remove from first gridview. Then I have to search the rowsbylocation.following ismy codeit fetches the list in gridview& move rows from one gridview to anothe

1. how toremove selected rows from gridview & list?

how to search by location.

[code]....

Posted: Nov 23, 2010 07:00 AM

View 1 Replies!   View Related
Forms Data Controls :: Copy Rows From Gridview Selected Items?
have a page that has a results gridview where I have all rows with a chekbox. when I click on the checkbox I try to create an excel filethis is method content:

DataTable MyData = new DataTable();
//recorrido sobre los elementos seleccionados6
foreach (GridViewRow row in gvwDbf.Rows)

[code]...

The problem is that excel file is totally empty. When I trace on the error I find that (item on bold above) dt datable has current record as I expected but Mydata table has nothing inside. shouldn't I use import statement? How can I get the row copied? I intend to have a full table made by every record coming from parameters of each query which is performed inside a for each sentence

Posted: Apr 01, 2011 04:41 AM

View 1 Replies!   View Related
Forms Data Controls :: Disable Check Box For Selected Rows In Gridview?
I am using two Gridview controls with in a page. Gridview1 contains pending records(on left side). Gridview2 contains Transfer records(on right side). I added check box for both grids. I have two buttons Add & remove Button in between the grids.I loaded the pending records(Gridview1) from my stored proc. By selecting checkbox user can move rows from leftside to right side with add button & rightside to left side with remove button vise versa. Up to this everything works fine.

Gridview 2 contain the records which are moved from Gridview 1. In gridview 2 I am binding another table .i,e Records in Process Table from my database. This table has same column name. This table records shows to the user Records which are in process.I want to disable checkboxes for Records in Process Table rows in gridview 2. So that they can't move the records to Gridview1.in which event i should write the code. ??

Posted: Dec 01, 2009 02:50 PM

View 3 Replies!   View Related
Forms Data Controls :: Gridview Concerning Selected Rows And Inline Editing?
Using a gridview with paging, sorting, inline editing, and selection enabled. I noticed the following:1. after selecting a row, then sorting, the selection sticks to the position in the grid, rather than the actual data. I would have expected it to either stick with the data, or clear the selection so nothing is selected. I would just assume clear the selection rather than have it actually change, like it is now. When a row is selected, I'm showing detail information about that specific row below the grid, so when a user does this, then sorts, the selected row changes and the new selected row's detail info shows below the grid. How should I go about stopping this? Hook into the gridview's Sorting event and set the selected row back to -1 (for nothing selected)? I assume that would work but I was compelled to post anyway to see if there is something else I should be doing...

2. I have not tested yet, but I assume the same thing would happen when paging occurs?3. another issue I'm having is when a user enters into edit mode for a row. This also does not clear a previous selection, so if a user had first selected a row, which shows the detail info for that row below the grid, then they hit the edit button for a different row, now on screen at the same time is a selected row (visible by selectedRowStyle), it's detail info below, and a completely different row in edit mode... this is a very confusing scenario for a user. I either need to ensure that any selection is cleared once in edit mode, OR sync these up so that the row in 'edit' mode also becomes the selected row... what do you guys/gals normally do for this situation? I'm thinking syncing up so that the row in edit mode is also selected sounds preferable... how would I do that?

Posted: Dec 18, 2010 09:31 PM

View 2 Replies!   View Related
Forms Data Controls :: GridView Selected Row Highlighted / Keep The Gridview Rows Highlighted As The User Clicks Through The Grids?
I have a few gridviews on my page. Each gridview row click drives another grid. I need to keep the gridview rows highlighted as the user clicks through the grids. So it is eazy to figure out which rows are being selected on each grid. How can I do this.

Posted: Jul 16, 2010 09:39 PM

View 2 Replies!   View Related
Forms Data Controls :: Insert Database NULL If Drop Downlist Item Is Not Selected?
on my aspx I have the below DDL

<asp:DropDownList ID="ColorDDL" runat="server" DataSourceID="ColorObj"
DataTextField="Size" DataValueField="BustId" Width="150px"
AppendDataBoundItems="True">
<asp:ListItem Value="-1">(Optional)</asp:ListItem>
</asp:DropDownList>

If the user does not select an item I get an exception when i call the ObjectDataSource Method and DAL as below to insert into database

ProfileObj.InsertParameters["ColorId"].DefaultValue = ColorDDL.SelectedValue.ToString();

What I want to do is insert a database NULL instead.

Posted: Sep 01, 2010 01:05 AM

View 3 Replies!   View Related
DataSource Controls :: How To Select Rows From A DataTable And Create A New ViewList With The Selected Rows Only, While ...
I have one big DataTablewith X rows. I want to select Y rows from it and bind them to a newViewList. While doing it, I want to delete these rows from the DataTable (Having X - Y rows).

What is the best and fast wayto do it?

I don't know if it is better to create a new DataTable to have the Y and after that bind them to a ViewList or something else?

I'm alsolooking for example in code how to select/delete rows from DataTable.

Posted: May 31, 2010 04:10 PM

View 1 Replies!   View Related
AJAX :: Gridview - Multiple Checkboxes Are Selected The Button Should Become Visible (extract Data GUI) Concerning The Checked Rows
I have a GridView with a column that has check boxes. A button is also present (outside of the GridView) .. but until a checkbox is selected it should be non-visible. In the case that a checkbox .. or multiple checkboxes are selected the button should become visible (and hopefully I can extract data (GUI) concerning the checked rows - irrelevant for now). I need to achieve this without any postbacks .. upon which selection of the button will enable me to perform some SQL.

Posted: Nov 24, 2009 04:34 AM

View 1 Replies!   View Related
Adding Multiple Rows, Displaying Session Rows And Then Doing One Insert?
I need to produce a from where I can add multiple parts. Each time a user enters a part number, the description should be populated. The user can then click add and this part and description will be shown below. They have the option to add as many parts as they require. Once all parts are added the user fills in some general info eg description and then once a submit button is clicked all part info will be inserted into a table and general info will be inserted into another table with one unique ID.

Posted: Apr 14 10

View 5 Replies!   View Related
Validation On CSV File And Insert Rows Of CSV File Into Multiple Tables Of SQLServer Database?
I have to upload a csv file, perform some validations (No of coloumn must be 8, if any cell in Coloumn 2 contains a text "Answer" it must be followed by a "Question" above in same coloum) and then insert the values into database as following

1. worksheet name should be inserted into "tblSection" table database.

2. The rows those contain text "Question" in 2nd coloumn of CSV file will goes into "tblQuestion" table.

3. The rows those contains text "Answer" in 2nd Coloumn should be inserted into "tblAnswer" table of db.

Posted: Aug 12, 2009 03:37 PM

View 1 Replies!   View Related
Javascript - How To Insert Selected Item Text From Checkedlistbox To Gridview Dynamically
My requirement is, i have a checkedlistbox, and i want the selected item should be inserted into the gridview using javascript, in grid i want only two columns i.e. selected item text and another is checkbox.

Posted: Nov 19 10 at 10:39

View 1 Replies!   View Related
2 Rows For Each Database Record In A Gridview?
I am working on a web page that will display records from a database. Each record has a total of 8 columns. One column may be as long as 500 characters, and the other 7 columns are between 5 to 25 characters. For each record in the dataset returned from the database, the short columns should be above, and the long column below.

In other words, each database record is made of two rows, the 7 short fields in the top row (each field in a cell), and the long field in the bottom row in one cell. Both rows should be similar in length.

Posted: Feb 25 10

View 4 Replies!   View Related
Forms Data Controls :: Limit Number Of Selected Rows In Data Source For GridView?
I'm sure it was discussed hundred of times, but maybe this time will elucidate some new points )

The question is: do I need to limit number of selected rows in data source for GridView?

When I use paging in GridView does limiting selected rows make GridView work faster?

Now I use ObjectDataSource with Linq in functions.

[Code]....

Does this make sense or I can just use LinqDataSource without thinking of selected rows?

Posted: Apr 30, 2010 07:56 AM

View 2 Replies!   View Related
Forms Data Controls :: Add Rows To Database In Gridview?
I'm developing an ASP webshop website (in VB). I've attached an sql database and put a gridview on the form which pulls up the product details from the database. I can turn on Edit and Delete in the gridview so it is easy to modify the products but how can I add new rows?

Posted: Jun 15, 2010 03:11 PM

View 1 Replies!   View Related
SQL Server :: Insert Gridview's Multiple Rows Into Sql Server Through Store Procedure?
Actually I have a gridview with many rows and I want to insert the all rows in sql server through one store procedure first row can inserted but what should we do for other rows

Posted: Jan 23, 2011 06:47 PM

View 3 Replies!   View Related
Add Only The Selected Row In The Database From Gridview
In a grid veiw, there is a checkbox.I want to add only the selected row in the database. How it can be done by using Checkbox.what is the code for this.

Posted: Apr 28, 2009 07:06 AM

View 4 Replies!   View Related
Forms Data Controls :: Add / Remove Rows In Gridview But Leave In Database
I have 2gridview with add/remove buttons between them. I want the user to select an item in one gridview and based on the button clicked I need to remove the row from one gridview and add it to theother. I can idenfity which row is selected but I don't know how to remove/add the rows.

Posted: Feb 22, 2010 11:07 PM

View 6 Replies!   View Related
Forms Data Controls :: Unable To Update Gridview Rows Into Database
I am unable to display data in gridview by selecting dropdowns and text box values.

Secondly, I am failed to update data into database.

Here is my code:

[Code]....

Posted: Dec 27, 2009 12:04 PM

View 2 Replies!   View Related
C# - Insert Data In Gridview Without Using Database?
insert in gridview without saving data in Database?

Posted: Mar 12 at 8:35

View 1 Replies!   View Related
Copyright 2005-08 www.BigResource.com, All rights reserved