create instance of new datarow

  • Thread starter Albert via DotNetMonster.com
  • Start date
A

Albert via DotNetMonster.com

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
 
B

bruce barker \(sqlwork.com\)

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)
 
A

abentov via DotNetMonster.com

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/Forums.aspx/asp-net/200606/1
 

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

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top