Click here to Skip to main content
15,749,281 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi friends I am create table RowNo--> Numeric; Name-->Varchar(50); Address-->Varchar(50); City-->Varchar(50)

I am taking all this fields in gridview and i want to save this record in database table Emp So please tell me how to do it.
Thanks7872 16-May-13 8:29am    
How you filled the gridview?i mean from where the data coming into the gridview?
moresaurabh007 23-May-13 4:57am    
I want to take data from textboxe to gridview?
Thanks7872 23-May-13 5:03am    
first create fields on your form(on aspx page) using textbox etc.Then on click of button enter that data into database using INSERT QUERY.At the same time fill your gridview using database.By doing so you will get latest inserted values also from database in gridview.[Gridview doesnt store any data,it is used just to display data]
moresaurabh007 27-May-13 2:17am    

Directly data not store in gridview is not possible.but 1st data store in database after that, that stored data bind to ur required gridview is possible.
>first data store in to data base(using insert query).
>retrieving data from data base(using select * query) and
>finally that data bind to gridview(using gridview.bind()).

thank u.
Share this answer
You cannot save the data into gridview. Rather you will display the data using gridview. For that
first Write a stored Procedure that returns dataset of the all the columns in the table emp.

Create Procedure getdetails
select * from emp

Then Take a Class file and write a method that use the the above stored

public dataset getdetails()
return sqlhelper.executedataset(strcon,commandtype.storedprocedure,"getdetails");

where strcon is your connection string

Then in the code behind file call this method by creating the object for the class and bind the returned data to tour gridview. like
cls obj=new cls;
dataset ds=obj.getdetails();

Hope this will help you. and sqlhelper above in class file needs dll
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900