C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Interview   Jobs   Projects   Offshore Development    
Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing | Talk to Us |



My Profile

Gifts

Active Members
TodayLast 7 Days more...







Binding data to a DataGrid


Posted Date: 21 Mar 2007    Resource Type: Code Snippets    Category: ADO.NET

Posted By: Thiru Balaje       Member Level: Silver
Rating:     Points: 10



This code shows how to bind data to a data grid.


private void btnLoadData_Click(object sender, System.EventArgs e)
{
string connectionString = "server=MyServerName; database=MyDatabaseName;uid=sa; pwd=;";
SqlConnection conn = new SqlConnection(connectionString);
string cmdString = "SELECT * FROM Articles";
SqlDataAdapter dataAdapter = new SqlDataAdapter(cmdString, conn);
DataSet ds = new DataSet();
dataAdapter.Fill(ds, "article");

dgDetails.SetDataBinding(ds, "article");
}


"dgDetails" is the name of the DataGrid.




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Create a DataTable, add rows and read records
Previous Resource: Filling a DataSet with data from multiple tables
Return to Discussion Resource Index
Post New Resource
Category: ADO.NET


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

budget conference call

Contact Us    Privacy Policy    Terms Of Use