SQL Server :: How To Insert Data Based On Gridview User Value On Row
Aug 24, 2010
I have three column comes from database table(Table1) and one column is for entering data for the user let us consider it look like this
ItemNo ItemName Qty uservalue
001 A 50 20
002 A 20 5
003 B 50
004 C 60 10
005 D 40
006 E 90 15
........
If its 300 row from database to gridview it will show 50 record with page navigation..What i need is i need to insert data in to database table which gridview row has user value..The output of the another table(Table2) will look like this after insert
ItemNo ItemName uservalue
001 A 20
002 A 5
004 C 10
006 E 15
View 8 Replies
Similar Messages:
Aug 11, 2010
I have a gridview object to which I added
<asp:TemplateField >
<ItemTemplate>
<asp:CheckBox ID="chkCopy"
OnCheckedChanged="chkStatus_OnCheckedChanged"
runat="server" />
</ItemTemplate>
</asp:TemplateField>
The page count is set to 10, when the user checks the checkbox(es), I will need to insert those records in a table. 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();
View 4 Replies
Dec 31, 2010
would like to know how to feed data for columns like Logged-in user id , Updated date, created date etc... I have these audit columns on each and every table. User id: Logged in user idCreated date or modified date: current system date time. and don'nt want to show these columns on the UI as well.
View 7 Replies
Jan 26, 2010
i got the task to bulk insert using gridview....based on my customer Id & customer name i need to insert bulk records through grid view.... and aso i want to view those bulk records in grid view by id....
View 1 Replies
Feb 3, 2011
I can't for the life of me remember how to do this and I'm sure someone will answer this pretty quickly. I need to insert or update a record based on if it exists so in the SP I need to do:
SELECT * FROM table1 WHERE LinkedID = @ID Then I need to check if any rows were returned and apply it to an if statement which is where my mind is blocked.
View 2 Replies
May 17, 2010
i want to use a grid view for data insert user can insert more than one row.
View 4 Replies
Jul 17, 2010
i have displayed a xml file in the tree view form by binding them....now i want a sample code to access the nodes which are being selected and to display dynamically in a grid view ..in asp.net/c#
View 4 Replies
Oct 20, 2010
I have enabled User Rolls and assigned several Roll names such as 10, 11, 12, etc. I have a SQL Table that contains various fields of information including one named AuthorizedUserRoll, it's nchar(2).
A logged in user should only see the records in Gridview that matches his/her roll.
I'm using Web Forms and VB.
View 1 Replies
Feb 19, 2011
I have 3 tables in Oracle database. From my asp.net C# page, I am inserting records into all three tables as shown below:
[code].....
My question is, how do I make sure that either all the above are executed or none is executed in C#.
If the first 2nd or 3rd insert fails, everything should fail.
View 3 Replies
Feb 28, 2014
I have register table in database that it has age column and I have textbox in register.aspx page that users can enter their age in it...
I want if users enter number between 10-20 in textbox it insert in age columnĀ "less than 20"
And if they enter number between 20-30 it insert into age column "more than 20"
How I can do it?
View 1 Replies
Apr 29, 2010
I have a gridview which I am binding through code behind, I want to filter the gridview based on the value given by the user in textbox. It would be great if I'll be able to filter the gridview without any postback.
View 3 Replies
May 10, 2010
I wont to create a User Control based in gridview that have the edit add delete incorporate,the problem is these:In the admin part of my web site i have to repeat the same action for view add delete update the data for different datasource.I wont to create a generic gridview that have incorporate these action.The gridview can take a xml file for configure him self dependently of the request for desplay the data.
View 1 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
Apr 24, 2010
I'm using an edittemplate to handle both editing and inserting for a Formview. In Insert mode, the Identity parameter is not needed (and cannot be used in the parameter list). In Edit mode, I need the bound value to know which record to update. So, what I tried to do is set the Text property in the OnDataBinding method.
[Code]....
The result is that the field is bound for Insert anyway, shows up as a parameter, and my insert statement fails (since this extra field messes up the field order of the parameters). Plus, it is always null in Insert mode by definition.
Is the OnDataBinding method too late to clear the property? If so, where can I do this, since PageLoad is too early (the template has not loaded yet and I cannot Findcontrol the field. Or is there a better way to handle all this?
View 7 Replies
Jan 23, 2011
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
View 3 Replies
Mar 24, 2010
I am selecting the date field in the 'dd-mm-yyyy' format by using SQL Codes(103,105...).While inserting I want the userto insert the date in same format(dd-mm-yyyy) but it will not happening as in SQL Server we need to insert the date in'mm-dd-yyyy' format.Pls send me insertion query in sql to achieve this.Pls respond me ASAP.
View 4 Replies
Apr 15, 2010
How to insert data from local SQL server to remote SQL server (without using linked server) like below?
insert * into [remote server].[northwind].orders
from [local server].[northwind].orders
View 4 Replies
Dec 7, 2010
I am doing a data warehouse project.I have two tables tblA (id, type) and tblB(city, no_crimes, type).I want to create (insert) a number of rows based on the value of no_crimes.For Example, in tblB(Leeds, 2000, murder). SO, I need to insert 2000 rows into tblA by a single INSERT statement (not 2000 statements).
View 3 Replies
Aug 18, 2010
i've created a webform with one gridview having connected with the database using datasource. i.e password database with three colomn .
now want to insert the custom dropdown button using server control for each column.
when i select the dropdown list the list should display the value as required.
e.g if i click the uname dropdownlist then it should show the list of names.
if i click on pwd dropdownlist then it should show the list of numbers.
if i select any one of the value in the dropdown list then it should insert into the
database.
can i get code on this type of question...?
View 3 Replies
Sep 8, 2010
When someone logs on to my site. I want to direct them to their own home page. If the user has the id of 1. They would go to[URL] I already have the login and id setup. I am not sure how to incorporate it into the url.
View 2 Replies
Nov 10, 2010
[Code]....
this is my html code
[Code]....
this is my code behind
[Code]....
this is my bal code
acuttally
in my javascript popup i am getting the checked values but i need it in record by record in the lblsave data
View 2 Replies
Jun 29, 2010
Just wondering the best way to do something. I want to fill up fields on a website based on a selection from a list. For example, the user selects "Melbourne" from a list of Australian capital cities and the page will fill up with information from the database relating to Melbourne.
View 1 Replies
Apr 7, 2010
I would like to know how to show data based on user name and password?
Example:
User name: user1
Password: pass1
How to show information regarding the name user1 and pass1 (Students, teachers, etc...)?
[Code]....
View 6 Replies
Feb 6, 2011
I want to generate 30,000 cards and each card must be duplicate check with database. In my card, there are 2 things. Serial No and CardID. If any card already exists then I generate another card id but with the same serial no.
So how faster way I can generate 30,000 card with duplicate check? Which one I have made application, it takes about 25 minutes to insert.
View 33 Replies
Feb 27, 2011
As I know, we can use INSERT INTO (....) SELECT FROM command to select data from one table and can insert into another table.
Now I need instead of 1 table, I want to select data from one table and Insert into another 2 tables.
Shall I write another INSERT INTO (..) SELECT FROM command or is there any other way?
View 7 Replies