Click here to Skip to main content
15,916,379 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
By using below code,i can't work in asp.net (vb)

GridView1.DataSource = ds.Tables("emp1")
Posted

SqlDataAdapter adap = new SqlDataAdapter("select * from table", con);
con.Open();
DataTable dt = new DataTable();
adap.Fill(dt);
GridView1.DataSource = dt;
GridView1.Databind();
 
Share this answer
 
Hi,

For the simple way...

1) Add a new LinQ to Sql class to your project. It opens a designer. Drag your table from the database explorer to the designer. Then it will create a datacontext. save.

2) Add a linq data source to your aspx page. Configure it to choose the data context you added above. You may optionally choose whether to edit,delete or update

3) Set this linq data source as the data source for the grid view.

Ask me if any doubts
 
Share this answer
 
Comments
somil030 11-Feb-11 23:20pm    
without using class????
what modification in this code ....GridView1.DataSource = ds.Tables("emp1")
Albin Abel 12-Feb-11 0:56am    
Look at Sandeep's answer. My answer is an alternate way. For LinQ you will be using the the context class
Try:
VB
GridView1.DataSource = ds.Tables("emp1") 
GridView1.Databind()


You still didn't picked a beginner book or an online tutorial?
 
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