Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
|
C# 2005 For discussion of Visual C# 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 6th, 2008, 08:50 AM
Authorized User
 
Join Date: Jul 2006
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem populating DataGridView

Hi there

I have a problem. Im populating a datagridview in runtime.
Connecting my datasource to the DataGridView results in a Datagrid with all the collums in the datasource. But i dont want all collums in the data grid. How can i make this happen. Because the other values i want to bind to labels and txtboxes.

Here is my code

private void LoadData()
{
  SqlConnectionStringBuilder bld = new SqlConnectionStringBuilder();
  bld["server"] = ".\\sqlexpress";
  bld["AttachDBFileName"] = "D:\\FolktaleDB.mdf";
  bld["user Id"] = "sa";
  bld["Integrated security"] = "sspi";
  string connectionString = bld.ConnectionString;

  conn = new SqlConnection(connectionString);
  qry = "SELECT AddressId, Address1, Address2,
                City, State, ZipCode, Country
         FROM Address";

  da = new SqlDataAdapter(qry, conn);
  conn.Open();
  ds = new DataSet();
  da.Fill(ds, "Address");
  bsource.DataSource = ds.Tables["Address"];
  dgvBlock.DataSource = bsource;

  richTextBox1.DataBindings.Add("Text", bsource, "AddressId", true);
            conn.Close();
}

I only want the 2 fields in the datagrid and the others binded to the labels and txtboxes.

I hope some one can help me.

Kind regards

MacDevv






Similar Threads
Thread Thread Starter Forum Replies Last Post
problem in populating datasheet ...... sms Access 4 June 1st, 2008 03:47 AM
Populating a DataGridView sagarbhargava Visual Basic 2005 Basics 2 April 26th, 2007 07:03 AM
Problem with DataGridView rgassociate Visual Studio 2005 0 January 26th, 2007 06:10 PM
DataGridView Problem testsubject Visual Studio 2005 0 January 2nd, 2007 08:55 AM
DataGridView Problem bipulbasakdhaka Visual Basic 2005 Basics 0 November 8th, 2006 01:34 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.