Members Login.
 

Please register HERE to be part of our Community
Contest of the Day.
 
Current Promotions.
 
Earn By Posting
 
Participate in forum and Earn $$$.
  • Referrer Credit - BRL$ 100
  • Positive Rep Cr. - BRL$ 3
  • New Thread Cr.- BRL$ 3
  • Posting Cr. - BRL$ 2
  • Post size Credit
Full List of BRL$ Earnings
Sponsors.
 


ASP / ASP.NET Discussion related to web development using ASP & ASP.NET. Tutorials, source code, tips and tricks related to ASP and ASP.NET programming.

Expired Thread The thread "How to bind datagrid in asp.net" has not received any replies for a month. It has been automatically closed as a result. You may start a new thread on the topic if the information in this thread is not sufficient.

Closed Thread
  #1 (permalink)  
Old 03-18-2008
New Foot Prints
 
Join Date: Mar 2008
Posts: 7
BRL$: 93.42
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
techno is on a distinguished road
Default How to bind datagrid in asp.net

Can anyone tell me how can I bind datagrid in asp.net? I am using c# with it.

thank you


Current Promotions... Post a New Thread anywhere on Web Development Board to earn BRL$ 5 for every thread. Post a new Reply there and earn BRL$ 3 for every reply.
Important - Read before posting Please carefully read the Global Rules and Posting Rules for GPT / Buy - Sell Offers / Link Exchange sections before posting.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 03-18-2008
Jr. Member
 
Join Date: Mar 2008
Posts: 263
BRL$: -26.73
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 35
mira is on a distinguished road
Default Re: How to bind datagrid in asp.net

There are two ways of binding datagrid in asp.net

1) Data reader
2) Data adapter

HTML Code:
Imports System.Data.SqlClient
   For select query to a SQL database, you must create a SqlConnection to the database passing the connection string, and then construct a SqlDataAdapter object that contains your query statement.  To populate a DataSet object with the results from the query, you call the command's Fill method. 
  
Dim cn As New SqlConnection("server=yourservername;database=pubs;uid=username;pwd=")
cn.Open()
Dim cmd As New SqlDataAdapter("select * from Authors", cn)

Dim ds As New DataSet()
cmd.Fill(ds, "Authors")

The advantage of using a dataset is that it gives you a disconnected view of the database.  You can operate on a dataset in your application, and then
reconcile your changes with the actual database later.

DataGrid1.DataSource=ds.Tables("authors")
DataGrid1.DataBind()

Hope it will help you bind grid using asp.net
It is a code in vb.net you can convert it using c#


Current Promotions... Post a New Thread anywhere on Web Development Board to earn BRL$ 5 for every thread. Post a new Reply there and earn BRL$ 3 for every reply.
Important - Read before posting Please carefully read the Global Rules and Posting Rules for GPT / Buy - Sell Offers / Link Exchange sections before posting.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Closed Thread
Expired Thread The thread "How to bind datagrid in asp.net" has not received any replies for a month. It has been automatically closed as a result. You may start a new thread on the topic if the information in this thread is not sufficient.



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
correct use of bind variables Rss_Feeds PHP 0 07-16-2007 11:22 AM
Download the ASP.NET Futures Release Rss_Feeds ASP / ASP.NET 0 07-09-2007 04:22 AM
How to Develop Enhanced Web Experiences with ASP.NET AJAX Rss_Feeds ASP / ASP.NET 0 07-09-2007 04:22 AM
Explore Web Development with ASP.NET 2.0 Rss_Feeds ASP / ASP.NET 0 07-09-2007 04:22 AM
ASP.NET 2.0 CSS Friendly Control Adapters 1.0 Released Rss_Feeds ASP / ASP.NET 0 07-09-2007 04:22 AM


 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103