Last post Jan 25, 2008 11:22 AM by vinz
Jan 25, 2008 02:12 AM|ramesh1520|LINK
I got the data in to gridview's one column,in another column i am accepting user's data. Now i want to store data from the 2 columns into the database.Can u tell me a way.Code is appreciated.
Jan 25, 2008 02:40 AM|frostfang|LINK
Is there 2 seperate tables in the database or are they going to the same table?
Is there going to be a button that says 'insert data into database' ?
Jan 25, 2008 03:40 AM|ramesh1520|LINK
Yes an insert button is there.No only one table.
Jan 25, 2008 03:58 AM|kakali|LINK
You can retrieve the data entered by user in the button click event.
Response.Write(row.Cells.Text); //Get any cell's text
You can send the retrieved text to your database.
Jan 25, 2008 04:09 AM|TATWORTH|LINK
First a general point: go to Edit profile (hyperlink in top right hand corner), choose site options, change content editor to enhanced and save. This will give an additional line to the message editor toolbar which includes an option to insert code without
gratuitous blank lines being added.
Now as to your immediate problem: Loop through the lines of the gridview. On each row select the data from the row. If you are using templated columns you will need to use FindControl to locate the control on each line. Once you have the values, the update/insert
is now a matter of calling the required stored procedure.
Jan 25, 2008 04:43 AM|ramesh1520|LINK
Are u telling me to keep an extra button and write in that event?Is it possible to write in rowcommand event?
Jan 25, 2008 04:53 AM|frostfang|LINK
Yes you will most probably need a button to take the data from the gridview and post it to the database.
Jan 25, 2008 05:12 AM|TATWORTH|LINK
I think you will the following useful:
How to access the different controls inside a GridView control. http://www.codeproject.com/KB/dotnet/AccessingControlsInsideGr.aspx
The article shows how to iterate through a GridView and to use FindControl.
Jan 25, 2008 06:29 AM|ramesh1520|LINK
I am not getting the selected value in the dropdownlist in to the database.Even if i change and selected new value its again taking only one value for all rows.Can u tell me what to do?
Jan 25, 2008 11:22 AM|vinz|LINK
This might help you..