DataSource Controls :: Save Data Into Sql Database From Gridview
Mar 27, 2010
i'm new to programming and i'm doing a project of ana e-store, i have a data gridview that brings data from a data base and it have to more templeate files one a textbox and the other one is a label. and i have a button outside the grivdview. what i need that when i press on this button it will take the values from the grid view and insert them into a new sql table.
and here is the VB code that i'm trying to use with no luck : [Code]....
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.
I have a from in which upon pressing submit button all the data were appear on the grid.But i want to do one thing over here which is that at the end of the gridview there was a button upon clicking on that button all of the data were go directly to the database...
I am developing a project using Visual Web Developer 2008 express. I am displaying the excel data set into Grid view, each execl sheet having 400 records, i want save this whole grid view data into mysql table with single clickToacheive above task shall i need to create a table in mysql database having same excel names.
I had just started with Visual Studio 2008 + VB.net. I've now designed my tables, and basic gridview functions properly.Now I'm faced with the problem of having to calculate a value based on 2 - 3 columns/data in the gridview, display the result in an existing column in the same gridview, and saving the calculated value in the datasource.I had initially created the "Total" column as a textbox displaying a manually calculated amount that is saved in the datasource. Now, I want to change the field to auto-calculate based on 2 other columns.
I want to add gridview row data into to data base I am doing it perfectly.My problem is that want all gridview row data save and then web method should be called but in my cause one gridview data save in array then call webmethod,then other row data save in array then call webmethod called this process should be so on.But I want it webmethod should be called when all gridview row save in array.
If in one form upload image form we enter ID in textbox againts ID label and upload an image file using fileuploadcontrol when we click on upload button image save in DB and in next form view image when we enter ID in textbox againts label enter ID. Images show in GRIDVIEW having columns (ID,images) ...
I have another problem is that I have Placed a file upload control in Empty template of Gridview to have multiple record insert. I have used viewstate to save multiple record into database. But problem is that I am able to find the control but it not giving any value.I have following code.
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)