SetDataBinding

M

Michael

Hi guys,
I'm new in developing applicationa in C# and I have a
very strange effect to display my data in the DataGrid:

the method SetDataBinding is unknown for my DataGrid

I use the following codesample:
myDataGrid.SetDataBinding(myDataSet, "Customers");

please can you help me?

Thanks...
 
C

Cowboy \(Gregory A. Beamer\)

This is the example you see in the Microsoft .NET help file:

private void SetSourceAndMember(){

DataSet myDataSet = new DataSet("myDataSet");
DataTable tableCustomers = new DataTable("Customers");
myDataSet.Tables.Add(tableCustomers);
// Insert code to populate the DataSet.

// Set DataSource and DataMember with SetDataBinding method.
string member;
// The name of a DataTable is Customers.
member = "Customers";
dataGrid1.SetDataBinding(myDataSet, member);
}

The SetDataBinding is a runtime method, which is useful if you are dealing
with the possibility of reuse (ie, you can set multiple tables to the
DataGrid, depending on your needs). You can also bind the specific table,
like so:

dataGrid1.DataSource = myDataSet.Tables[0].DefaultView;
dataGrid1.DataBind();

The tables collection can also be accessed by name.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

**********************************************************************
Think Outside the Box!
**********************************************************************
 
G

Guest

I used the example from the Microsoft .NET help file
but the interesting thing is, that the
method "SetDataBinding" is unknown!

Is it possible, that something is missing or wrong in my
installation?

I use visual .net 2003 enterprise developer and a C#
project for mobile devices...

-----Original Message-----
This is the example you see in the Microsoft .NET help file:

private void SetSourceAndMember(){

DataSet myDataSet = new DataSet("myDataSet");
DataTable tableCustomers = new DataTable("Customers");
myDataSet.Tables.Add(tableCustomers);
// Insert code to populate the DataSet.

// Set DataSource and DataMember with SetDataBinding method.
string member;
// The name of a DataTable is Customers.
member = "Customers";
dataGrid1.SetDataBinding(myDataSet, member);
}

The SetDataBinding is a runtime method, which is useful if you are dealing
with the possibility of reuse (ie, you can set multiple tables to the
DataGrid, depending on your needs). You can also bind the specific table,
like so:

dataGrid1.DataSource = myDataSet.Tables[0].DefaultView;
dataGrid1.DataBind();

The tables collection can also be accessed by name.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

********************************************************* *************
Think Outside the Box!
********************************************************* *************
Michael said:
Hi guys,
I'm new in developing applicationa in C# and I have a
very strange effect to display my data in the DataGrid:

the method SetDataBinding is unknown for my DataGrid

I use the following codesample:
myDataGrid.SetDataBinding(myDataSet, "Customers");

please can you help me?

Thanks...


.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top