Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > create instance of new datarow

Reply
Thread Tools

create instance of new datarow

 
 
Albert via DotNetMonster.com
Guest
Posts: n/a
 
      06-29-2006
Hi,

Letís say that I have a class (MyRow) that inherits from System.Data.DataRow.


Is there a way to be able to add a parameter-less constructor and to
instantiate MyRow as follows:

class MyRow : System.Data.DataRow
{
MyRow(){
}
}

----
MyRow r = new MyRow().

I know the above hardly makes sense but in my case I want to inherit a typed
row form a typed DataSet.DataTable. Then I could add my own fields in
addition to the DataColumns already there.

This sounds suspicious to me, but I post it anyway,

Thanks in advance

--
Message posted via http://www.dotnetmonster.com
 
Reply With Quote
 
 
 
 
bruce barker \(sqlwork.com\)
Guest
Posts: n/a
 
      06-29-2006
sure. you will need to make a class that inherits from the typed dataset,
that overloads the row create methods if you want to use fill().
unfortunately you cannot override the indexer without editing the generated
code.

alternately, just edit the class file generated by the wizard, and add you
new properties.

-- bruce (sqlwork.com)


"Albert via DotNetMonster.com" <u18435@uwe> wrote in message
news:6280d94242c24@uwe...
> Hi,
>
> Let's say that I have a class (MyRow) that inherits from
> System.Data.DataRow.
>
>
> Is there a way to be able to add a parameter-less constructor and to
> instantiate MyRow as follows:
>
> class MyRow : System.Data.DataRow
> {
> MyRow(){
> }
> }
>
> ----
> MyRow r = new MyRow().
>
> I know the above hardly makes sense but in my case I want to inherit a
> typed
> row form a typed DataSet.DataTable. Then I could add my own fields in
> addition to the DataColumns already there.
>
> This sounds suspicious to me, but I post it anyway,
>
> Thanks in advance
>
> --
> Message posted via http://www.dotnetmonster.com



 
Reply With Quote
 
 
 
 
abentov via DotNetMonster.com
Guest
Posts: n/a
 
      06-30-2006
Hi Bruce,

Once I make a typed DS and include one table I automatically get 2 classes -
1 for the table and 1 for it's row.
Then I make a class that inherits from the typed row.

What I can't do is to overload the typed DataRow base constructor by
providing a parameter less one.

It takes only a RowBuilder object as a parameter.

Can u please provide me with an example of how to overload the DataRow
constructor to get no params?

Thanks in advance,
Albert

ps. By the way I haven't seen a way for instantiating a DataRow other than:

DataRow r = MyDataTable.NewRow();

--
Albert Benatov
Skype: abentov
http://albertbenatov.com

Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/For...p-net/200606/1
 
Reply With Quote
 
 
 
Reply

Thread Tools

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
How to create a new instance of an extended type Bryan Java 5 10-22-2006 11:36 PM
How do I create a insert command that will take a datatable or datarow as a parameter Rob Dob ASP .Net 0 09-28-2006 04:03 AM
Can you create an instance of a subclass with an existing instance of the base class? Sandra-24 Python 18 04-29-2006 04:01 PM
Create new instance of Python class in C Sybren Stuvel Python 5 09-10-2005 08:23 AM
how can I create a copy of a DataRow that lasts after datatable is cleared? Bennett Haselton ASP .Net 0 11-11-2004 09:35 AM



Advertisments