Hi I am returning an array of struct from my webservice. Is there a way to bind that array of struct to DataGrid. I am using C#. Following is my struct. - //Struct to be sent
-
public struct UserDataSent
-
{
-
public string userID , fName , lName , IMO , status, businessAddress, city, state, zip, telephoneNumber, mail;
-
}
5 5038
Hi I am returning an array of struct from my webservice. Is there a way to bind that array of struct to DataGrid. I am using C#. Following is my struct. - //Struct to be sent
-
public struct UserDataSent
-
{
-
public string userID , fName , lName , IMO , status, businessAddress, city, state, zip, telephoneNumber, mail;
-
}
I know that you can use an array or arraylist as the datasource of a datagrid. Could you add the items of the struct into an array and then use the array as the datasource of your datagrid?
Nathan
I know that you can use an array or arraylist as the datasource of a datagrid. Could you add the items of the struct into an array and then use the array as the datasource of your datagrid?
Nathan
Nathan,
it still doesnt work. If I turn Auto Generate Column to false and try to bind every field that it says "A field or property with the name 'LName' was not found on the selected datasource.
And if I turn Auto Generate columns to true and dont bind any column manually then it says
System.Web.HttpException: DataGrid with id 'dgCheck' could not automatically generate any columns from the selected data
What I am doing wrong?
Are you using a DataGrid or a DataGrid view?
The datagridview's datasource objects seem to auto-create columns based on public methods and not public variables
Such as: -
public string MyString
-
{
-
get
-
{
-
return "hi there";
-
}
-
}
-
Would create a column called "MyString"
Are you using a DataGrid or a DataGrid view?
The datagridview's datasource objects seem to auto-create columns based on public methods and not public variables
Such as: -
public string MyString
-
{
-
get
-
{
-
return "hi there";
-
}
-
}
-
Would create a column called "MyString"
I am using datagrid. And also I have struct defined as public with public variables in it.
As Plater said,
You need to put properties inside your struct. The gridview binds to public properties, not fields. -
//Struct to be sent
-
public struct UserDataSent
-
{
-
public string userID , fName , lName , IMO , status, businessAddress, city, state, zip, telephoneNumber, mail;
-
-
public string UserID {[indent]get { return userID; }
-
}
-
-
...
-
-
}
-
It maybe possible to bind to fields using code attributes, but if it is I don't what the attribute is.
Cheers,
Graham
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Ann Morris |
last post by:
INTRODUCTION
One of the most powerful aspects of .NET and Windows Forms is data
binding. Data binding is the process of associating user interface
(UI) elements with a data source to generate a...
|
by: Nony Buz |
last post by:
I have an Array of a struct that contains int's and a string. I
would like to display that in a DataGrid, how do I do it? There
will be an extra field that will get updated which is not in the...
|
by: Richard L Rosenheim |
last post by:
I have a dataset containing a parent table related to a child table. The
child table contains an ID field (which is configured as autonumber in the
datatable), the ID of the parent, plus some...
|
by: Brad Shook |
last post by:
I am trying to bind one column of a datagrid to a seperate textbox and
the rest of the fields to a datagrid. the comments are too large to
fit in a datagrid so I created a textbox below the...
|
by: p.mc |
last post by:
Hi all,
I'm having major problems with a userControl which contains a datagrid.
My problem concerns data binding.
The Page_Load() procedure calls the DataBind procedure to bind the
datagrid...
|
by: no |
last post by:
Hi all,
I have a dataset that contain 2 tables and a relationship between them
(master detail).
I bind this dataset to a form that include some textboxes that bind to the
parent record, and a...
|
by: Stephen Barrett |
last post by:
I have an application that was originally built with ASP.Net 1.1.
We finally got permission to migrate to 2.0. Due to time constraints we
migrated the web projects to 2.0 web application...
|
by: Tom Gur |
last post by:
Hi,
What is early/late binding ?
|
by: aarklon |
last post by:
Hi all,
recently a friend asked me is there any dynamic binding in C...??
to which i answered AFAIK it is in C++ only,
but he says it is valid in C.
if dynamic can be implemented via function...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
| |