Try This |
| Sujit Patil replied to touseef ahmed at 12-May-08 12:26 |
Use DataAdapter to fill data from db to dataset and then just bind that ds to your gridview like;
Dim ds As New DataSet
Dim cn As New SqlClient.SqlConnection(ConnectionString)
Dim adpt As New SqlClient.SqlDataAdapter("select * from urtbl",cn)
adpt.Fill(ds )
grdView.Datasource=ds
grdView.DataBind()
For more details go thr these links;
http://msdn.microsoft.com/en-us/library/bh8kx08z(VS.71).aspx
http://www.beansoftware.com/ASP.NET-Tutorials/DataSet-DataAdapter.aspx
To do vice-versa means to get all data of gridview into a ds you have to create a table and have to access a gridview row by row and then you can crate insert that row into table. like;
Dim cnt
For cnt = 0 To grvMsg.Rows.Count - 1
Str = grvMsg.Rows(cnt).Cells(0) ///////////this wil gives u text of 0 th cell of each row create a new row n just padd to one table. Same u can access other row data also
Next
Best Luck!!!!!!!!!!
Sujit.
|
|