|
|
 |
| ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ASP.NET 2.0 Professional section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.
|
 |

March 16th, 2007, 03:15 AM
|
|
Authorized User
|
|
Join Date: Nov 2006
Location: Bangalore, Karnataka, India.
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
How to display data into Grid View?
Hi
All;
I need to display the data (Fetched from data base table by SQL query) into a grid view.
I have no option to bind the grid view to the database.
So, how can I do this?
Any suggestion will be gladly accepted.
With Regards
Somesh
someshchaterjee
__________________
somesh chaterjee
|

March 16th, 2007, 08:29 PM
|
|
Authorized User
|
|
Join Date: Mar 2007
Location: , , .
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi,
What do you mean with your saying, 'I have no option to bind gridview to the database'??
I know two choices for binding data to gridview!
First, You can use sqldatasource sqldatasource.
Second, You can bind data in code behind without using sqldatasource control.
Please Focus on them.
|

March 18th, 2007, 02:51 AM
|
|
Authorized User
|
|
Join Date: Feb 2007
Location: , , .
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
What about the following, this is answering you question, cheers
Dim ds As New Data.DataSet
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim con As New SqlClient.SqlConnection("data source=Nesrine;initial catalog=ASPNETDB;integrated security=true")
Dim da As New SqlClient.SqlDataAdapter("select ContactId,Title,EmailAddress,FirstName,LastName from Person.Contact", con)
da.Fill(ds)
Me.DataGridView1.DataSource = ds.Tables(0)
End Sub
|

May 23rd, 2007, 03:01 AM
|
|
Authorized User
|
|
Join Date: May 2007
Location: Frankfurt, Germany, Germany.
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
1.put the sqldatsascource into your contentplaceholder
2. use the sqldatascource wizard to configure your *.mdb database
3.put the grid view next to your sqldatascource
4.use the gridview wizard to select your sqldatascoure
p.s
by configuring the sqldatascource you can set up a sql query
So long
|

May 23rd, 2007, 03:38 AM
|
|
Authorized User
|
|
Join Date: May 2007
Location: Frankfurt, Germany, Germany.
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I have also a question concerining sqldatascources using a button to change the datascource by click.
Does someone know the c# code for setting up a new sqldatascource by clicking a button?
So long
|

May 25th, 2007, 08:07 AM
|
|
Registered User
|
|
Join Date: May 2007
Location: guntur, ap, India.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Take one function like
private void fillgrid()
{
here take sqlconnection
and using sqldataadapter or sqlcommand select query for filling in girdview
like
sqldataadapter sqlda=new sqldataadapter(sqlquery,con);
or
sqlcommand sqlcmd=new sqlcommand(sqlquery,con);
for sqldataadapter take dataset
as dataset ds=new dataset();
and fill sqldataadapter with dataset for getting data like
da.fill(ds);
and write
gridview1.datasource=ds; // gridview1 is id of gridview.
gridview1.databind();
}
you call this function in page_load...
like
if(!ispostback)
fillgrid();
use this one .....
gud luck
bye
}
pavan
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |