Click here to Skip to main content
15,904,415 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear Sir,
I have one Gridview named Gridview1 in this Gridview there is 3 columns that is movie_name,movie_relase_date, movie_remove_date how to insert data in this gridview using insert comand...
plz help...
Posted

Create class for to use of properties
public class Movies{
public string movie_name{get;set;}
public DateTime movie_relase_date{get;set;}
public DateTime movie_remove_date {get;set;}
}

Insert Values to this class list
List<Movies> movieList=new List<Movies>{
new Movies{movie_name="ABC1",lase_date="01/01/2010", movie_remove_date="01/01/2010" }
new Movies{movie_name="ABC2",lase_date="01/01/2011", movie_remove_date="01/01/2011" }
}
</movies></movies>

Now Bind Data to Gridview
Gridview1.DataSource=movieList;
Gridview1.DataBind();
 
Share this answer
 
v2
Comments
Rajkumar_007 1-Apr-14 1:26am    
sir i have one table and i bind this table to Gridview1, i want to do insert data in this table through Gridview1...
[no name] 1-Apr-14 1:48am    
Could you show your code first? The we can guide you
Rajkumar_007 1-Apr-14 6:28am    
protected void Page_Load(object sender, EventArgs e)
{
OleDbConnection cn = con.GetConnection();
string select1="select movie_name,movie_relase_date,movie_remove_date,no_of_show from movie_detail"
cmd = new OleDbCommand(select1, cn);
dr = cmd.ExecuteReader();
gv_movie_detail.DataSource = dr;
gv_movie_detail.DataBind();



i want to insert record in this datasourse using commandField...
plz help...
[no name] 1-Apr-14 8:55am    
Use OleDbAdapter then it may help you to get list of values in a dataset

OleDbConnection cn = con.GetConnection();
string select1="select movie_name,movie_relase_date,movie_remove_date,no_of_show from movie_detail"
OleDbAdapter da = new OleDbAdapter(select1, cn);
DataSet ds=new DataSet();
da.Fill(ds);
gv_movie_detail.DataSource = ds;
gv_movie_detail.DataBind();
Rajkumar_007 2-Apr-14 4:38am    
Thank you sir... :)

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