Forms Data Controls :: How To Insert GridView Data Into Another Table
Oct 21, 2010
I have a tricky situation that I just cannot seem to figure out. I'm using ASP.NET 4.0. I have two databases (let's call them Northwind and MyDatabase for simplicity). I cannot modify the data in Northwind, but once I save a copy to MyDatabase, I can change it.
I have a GridView that shows all the tests associated with a patient. I first populate the GridView, retrieving all the tests in Northwind.Test that are associated to a PatientID. On a button click event, I need to: Create a new Patient record in MyDatabase.Patient (I've got this part done already).Use that newly created PatientID and INSERT all of the rows from the GridView intoMyDatabase.Test.
I have the PatientID available, I just don't know how to retrieve the data from the GridView.(Ideally) I would like to then be able to load that patient record in the future from MyDatabase and be able to UPDATE the tests in the GridView to MyDatabase.Test. I can load the tests into the GridView no problem. But I have no idea how I would save that data to a different datasource. Should I even be using a GridView, or something else?
View 1 Replies
Similar Messages:
Jan 11, 2010
How to display empty GridView to insert new record if no data retreived for some record on the result from data table?Actually i am trying to give a user an option to add recrod from Gridview. On result of some query it is perfectly displaying data and a footer row with the insertion textbox but when there is no data in the gridview it is not displaying. It should display with footer having insert textbox.
View 5 Replies
Jul 22, 2010
I have a gridview that I load with data from an Excel spreadsheet when the user pushes a button. I then want another button that would insert all the data from the gridview into a sql table when the button is pressed. I'm using vb.
View 4 Replies
Jan 31, 2011
inserting data from 1 table in 1 database to another database using web service to retrieve the data in a gridview in vb.net, 3-tier
View 6 Replies
Jan 31, 2010
how can i insert data in gridview from 2 table?
how can i bind the data?
View 1 Replies
Jan 7, 2014
how to insert data in DB table from view state gridview ?
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
this.GetMaxId();
this.GetPersons();
[code]...
View 1 Replies
Mar 26, 2016
i want to insert a gridview in table column on button click on web form..
View 1 Replies
Aug 11, 2010
I am working on a web app for an online photo album. It is the last project in Scott Mitchell's book: "ASP.Net 2.0 in 24 hours".
I am creating a page where users can enter new photo images. The functionality for uploading an image will come later. I am working on just inserting a new row into the Pictures table with an optional category, a required title and a required description.
I am getting an error when I try to insert a new row.
Here is a screenshot of the page with a shot of the dropdown list.
The Categories are user-specific. I am getting the correct values retrieved.
[URL]
There are two pretty simple database tables involved here.
NOTE: The CategoryID and PIctureID are both autoincrement integer columns.
[URL]
The page uses a DetailsView that uses a SqlDataSource that uses the Pictures table. (The DetailsView's Default Mode property is set to "Insert". The "Enable Inserting" checkbox is also checked.)
The dropdown list uses a dropdown control that uses a SqlDataSource that uses the Categories table.
When the "Insert" button is clicked the CategoryID value associated with selected (Category) Name on the dropdown list will be used along with the Title and Description values to insert a row in to the Pictures table. (If no Category value is selected, then a null value will be used for the CategoryID. This is OK because the CategoryID column in the Pictures table allows nulls.)
My problem is that I am getting this error:
Cannot insert explicit value for identity column in table 'Pictures' when IDENTITY_INSERT is set to OFF.
(FYI: I have the full version of both Visual Studio and SQL Server.)
Here is my source code for the page:
[Code]....
View 3 Replies
Jun 1, 2010
in my button4 click event, i want to insert checboxlist items to data table. first i want to delete all of the exisiting and then insert again.
my code is below but it is not working if you could explain anyone ?
in page load I have written code so that existing checkbox items are selected.
[code]...
View 5 Replies
Aug 20, 2010
how can i insert data into dyanamically created table from database
View 2 Replies
Oct 16, 2010
I want to insert data in grid or table form in sql server2005. Which control is better to use?
gridview or repeater
View 3 Replies
Jun 13, 2010
Basically i deal with two tables.i have a table T1 of the following format:id company_name i need to read this data and create a table T2 as followsi wrote the following code. it worked fine for retrieving data and modification but fails to insert the modified data into the 2nd table.the error is, it does not recognise the value for @token
ArrayList dynarr=new ArrayList(); // global variable
protected void Button2_Click(object sender, EventArgs e)
{
int row = 1; int i;
string strcmd = null;
string Connection = "Data Source=....";
SqlConnection conn = new SqlConnection(Connection);
string str = "select company_name from T1 where ID=@ID";
[code]...
View 2 Replies
May 3, 2010
I am using two tables if one table is master table that is list of products and their Id's.I bind all list of products in dropdownlist.If i select Product means i want to insert their Id in table's.How to done this in easy form.Any one can send easiest form of inserting.
View 3 Replies
Oct 19, 2010
I have grid view in ASP.Net 3.5. I need to add multiple blank rows in a gridview and then have to save them in database. How can I do that in most simplest way?
View 7 Replies
May 7, 2010
Am trying to use sqldatasource to insert into a table and it comes up with the error message" Could not find control 'txtLast' in ControlParameter 'LastName'.
View 2 Replies
Mar 4, 2011
I have a formview with insert function into "table1". In that formview i also have a dropdownlist listed with records from "table2". (This dropdown is of course instead of a textbox). get "table1" inserted when one of the field is from a different table?
View 1 Replies
Aug 9, 2010
I am having datagrid in that I have one column that should have table. Now I want to know that how can I include table in datagrid. My table values may differ from each rows in datagrid. So that also should be accomplished.
View 3 Replies
Aug 20, 2010
how can i dynamically insert datas from database into Table and display the table
View 1 Replies
May 7, 2010
I am passing a query string into a new page and want a detailsview to insert whatever comments a user enters
I am getting an error AlbumUID does not accept nulls error.
I thought I passed the query string value to the insert statement but I must have missed something
Here's what I have:
<asp:SqlDataSource ID="SqlDSAddComment" runat="server"
ConnectionString="<%$ ConnectionStrings:MyCDsConnectionStringHome %>"
InsertCommand="INSERT INTO [Comments] ([Comments], [Rating], [AlbumUID]) VALUES (@Comments, @Rating, @AlbumUID)"
[Code]....
View 6 Replies
Feb 6, 2011
It sounds pretty simple, but I can't find a way to make it work. I have a FormView with a InsertTemplate where it inserts the current logged in user's UserId and content from a HTMLeditor, and a EditTemplate where it retreives the current logged in UserId and shows content from database in the HTMLeditor.
How can I get it to show EditTemplate if the userId exist in the table, and InsertTemplate if the UserId does not exist in the table?
View 4 Replies
Mar 3, 2011
I have error:
Cannot insert explicit value for identity column in table 'UserDetails' when IDENTITY_INSERT is set to OFF.
I'm trying to insert a record through a BLL (Business Logic Layer) class with an 'Insert' button attached to the FooterTemplate of a GridView2. My code:
[Code]....
[Code]....
BLL layer code:
[Code]....
The field 'idUser' is autoincremented. When I use SqlDataSource with a DetailsView, add option it adds a record and autoincrements the 'isUser'.
View 7 Replies
Feb 7, 2011
i have a form with several checkboxes....i want to insert the selected checkbox values in to a single column in the sql database..
View 4 Replies
Sep 16, 2010
I want to add controls (or simply texts) to a ListView inside the ItemTemplate at run time.
The reason is that in my application I don't know in advance how many controls (or texts) I should insert.
For example I have to read the fields from a database table and insert in the ItemTemplate controls according to those fields:
<ItemTemplate>
<%# Eval("fieldname1")%> - <%# Eval("fieldname2")%> - <%# Eval("fieldname3")%> - .....
Afterwards I have to bind the ListView to the table content, so I need to preserve the <%# ... %> structure for the binding
View 3 Replies
Nov 16, 2010
i'm currently doing a shopping website. The customer will have to selected the item they want to buy and it will appear in the detail view when they click add in the grid view. I need the info inside the detail view to be insert into a database call Orderlist.
i've try using INSERT INTO OrderList (ProductName, Price,) VALUES (@ProductName, @Price) but it don't seems to work.
Was it because i can't insert it like this as it is detailview? This method can work if is Textbox instead of detailview.
View 5 Replies
Mar 30, 2011
i have a gridview of 8 columns.I need to extract the data row by row from the the first(Message) and the last(phone_no) column and to be inserted into my sql table named massMessage.I have the codes here. Apparently im able to only extract the phone_no. My message wasnt inserted.
protected void btnSave_Click(object sender, EventArgs e)
{
foreach (GridViewRow gvr in GridView2.Rows) //loop through GridView
[code]...
View 2 Replies