p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 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
Send a message via AIM to Somesh
Default 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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old March 16th, 2007, 08:29 PM
Authorized User
Points: 82, Level: 1
Points: 82, Level: 1 Points: 82, Level: 1 Points: 82, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2007
Location: , , .
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to JoinTTT
Default

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.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #3 (permalink)  
Old March 18th, 2007, 02:51 AM
Authorized User
 
Join Date: Feb 2007
Location: , , .
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #4 (permalink)  
Old 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
Send a message via Yahoo to DarkForce
Default

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #5 (permalink)  
Old 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
Send a message via Yahoo to DarkForce
Default

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #6 (permalink)  
Old 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
Send a message via Yahoo to pavank
Default

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Data Grid View Control tbreslin BOOK: Professional VB 2005 with .NET 3.0 ISBN: 978-0-470-12470-3 1 August 10th, 2009 05:47 AM
Paging Data grid view Prakash001 Visual Basic 2005 Basics 0 February 6th, 2008 04:07 AM
Deleting multiple rows in data view or grid deepakbachelor SQL Server 2005 1 December 7th, 2007 02:19 PM
custome display in grid view MunishBhatia ASP.NET 2.0 Professional 5 November 16th, 2007 11:45 PM
Data Grid View CoolDude C# 2005 3 March 10th, 2007 05:37 AM



All times are GMT -4. The time now is 08:56 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc