PC Review


Reply
Thread Tools Rate Thread

Derived Dataset and Datagrid binding

 
 
=?Utf-8?B?VmxhZCBBLg==?=
Guest
Posts: n/a
 
      10th Jan 2005
Hello.
For simplicity sake, I wanted to use a dataset as my business object, but
because I needed to implement a lot of business logic, I've just derived my
classes from the typed dataset (and datatable and datarow using ADO.NET
Dataset builder by Shawn Wildermuth).
Everything works great, but after binding my objects to a datagrid, I need
to change some small things for each row in the grid, so I'm implementing
Datagrid's OnItemCommand delegate which returns me DataItem inside the
e.Item.
The thing is, for some unknown to me reason, the DataItem is of type
DataRowView, and I can't cast it neither to my object nor to DataRow.
What can I do? How can I get the original object it was bound (at least I
think it was) to?
Thanks in advance.
 
Reply With Quote
 
 
 
 
Miha Markic [MVP C#]
Guest
Posts: n/a
 
      10th Jan 2005
Hi Vlad,

Yes, you always bind dataview (a wrapper around DataTable) and not
datatable.
Try with DataRowView.Row to get to the DataRow.

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
SLODUG - Slovene Developer Users Group
www.rthand.com


"Vlad A." <Vlad A.@discussions.microsoft.com> wrote in message
news:F450C972-C036-4233-AD4E-(E-Mail Removed)...
> Hello.
> For simplicity sake, I wanted to use a dataset as my business object, but
> because I needed to implement a lot of business logic, I've just derived
> my
> classes from the typed dataset (and datatable and datarow using ADO.NET
> Dataset builder by Shawn Wildermuth).
> Everything works great, but after binding my objects to a datagrid, I need
> to change some small things for each row in the grid, so I'm implementing
> Datagrid's OnItemCommand delegate which returns me DataItem inside the
> e.Item.
> The thing is, for some unknown to me reason, the DataItem is of type
> DataRowView, and I can't cast it neither to my object nor to DataRow.
> What can I do? How can I get the original object it was bound (at least I
> think it was) to?
> Thanks in advance.



 
Reply With Quote
 
=?Utf-8?B?VmxhZCBBemFya2hpbg==?=
Guest
Posts: n/a
 
      10th Jan 2005
Thanks a lot, works like a magic.
Now a have other problems, with my approach, but I think I'll overcome them.
Thanks again.

Vlad.

"Miha Markic [MVP C#]" wrote:

> Hi Vlad,
>
> Yes, you always bind dataview (a wrapper around DataTable) and not
> datatable.
> Try with DataRowView.Row to get to the DataRow.
>
> --
> Miha Markic [MVP C#] - RightHand .NET consulting & development
> SLODUG - Slovene Developer Users Group
> www.rthand.com
>
>
> "Vlad A." <Vlad A.@discussions.microsoft.com> wrote in message
> news:F450C972-C036-4233-AD4E-(E-Mail Removed)...
> > Hello.
> > For simplicity sake, I wanted to use a dataset as my business object, but
> > because I needed to implement a lot of business logic, I've just derived
> > my
> > classes from the typed dataset (and datatable and datarow using ADO.NET
> > Dataset builder by Shawn Wildermuth).
> > Everything works great, but after binding my objects to a datagrid, I need
> > to change some small things for each row in the grid, so I'm implementing
> > Datagrid's OnItemCommand delegate which returns me DataItem inside the
> > e.Item.
> > The thing is, for some unknown to me reason, the DataItem is of type
> > DataRowView, and I can't cast it neither to my object nor to DataRow.
> > What can I do? How can I get the original object it was bound (at least I
> > think it was) to?
> > Thanks in advance.

>
>
>

 
Reply With Quote
 
=?Utf-8?B?VmxhZCBBemFya2hpbg==?=
Guest
Posts: n/a
 
      11th Jan 2005
Is there a way to bind the datagrid to my actual object, and not the derived
datatable?
I have a feeling that the dataset.Bind checks if the object was derived from
a dataset or a datatable and if so, gets the default view.

Thanks again,
Vlad.

"Miha Markic [MVP C#]" wrote:

> Hi Vlad,
>
> Yes, you always bind dataview (a wrapper around DataTable) and not
> datatable.
> Try with DataRowView.Row to get to the DataRow.
>
> --
> Miha Markic [MVP C#] - RightHand .NET consulting & development
> SLODUG - Slovene Developer Users Group
> www.rthand.com
>
>
> "Vlad A." <Vlad A.@discussions.microsoft.com> wrote in message
> news:F450C972-C036-4233-AD4E-(E-Mail Removed)...
> > Hello.
> > For simplicity sake, I wanted to use a dataset as my business object, but
> > because I needed to implement a lot of business logic, I've just derived
> > my
> > classes from the typed dataset (and datatable and datarow using ADO.NET
> > Dataset builder by Shawn Wildermuth).
> > Everything works great, but after binding my objects to a datagrid, I need
> > to change some small things for each row in the grid, so I'm implementing
> > Datagrid's OnItemCommand delegate which returns me DataItem inside the
> > e.Item.
> > The thing is, for some unknown to me reason, the DataItem is of type
> > DataRowView, and I can't cast it neither to my object nor to DataRow.
> > What can I do? How can I get the original object it was bound (at least I
> > think it was) to?
> > Thanks in advance.

>
>
>

 
Reply With Quote
 
Miha Markic [MVP C#]
Guest
Posts: n/a
 
      11th Jan 2005

"Vlad Azarkhin" <(E-Mail Removed)> wrote in message
news:9DB44152-A3D0-4E8E-A16E-(E-Mail Removed)...
> Is there a way to bind the datagrid to my actual object, and not the
> derived
> datatable?
> I have a feeling that the dataset.Bind checks if the object was derived
> from
> a dataset or a datatable and if so, gets the default view.


AFAIK DataTable is never bound directly....

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
SLODUG - Slovene Developer Users Group
www.rthand.com


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Binding a Dataset to a Datagrid =?Utf-8?B?bWgxbWFyaw==?= Microsoft ADO .NET 0 22nd Mar 2005 03:17 PM
Binding dataset to datagrid and textboxes jason Microsoft Dot NET Framework Forms 2 23rd Nov 2004 05:21 PM
DataGrid Binding to subset of Dataset? J Microsoft C# .NET 1 15th Jul 2004 04:24 PM
Binding a datagrid to a dataset =?Utf-8?B?R2VyYWxkaW5lIEhvYmxleQ==?= Microsoft VB .NET 0 6th Feb 2004 10:06 AM
DataSet Property not re binding to datagrid Nick P Microsoft C# .NET 0 2nd Sep 2003 12:33 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:34 PM.