views:

518

answers:

3

I use Visual Studio 2008, .NET 3.5

In my project I have a DataSet called SubCategory. In it is a SubCategoryTableAdapter, with some methods, added in designer with right click -> add query. I can use these methods on my page in a ObjectDataSource object.

Now I would like to add my own method (for select) so that I could use it in ObjectDataSource object. I want to write this method by my self (and not in designer with right click -> add query). If I look into the code of SubCategory dataset, I can create partial class for SubCategory dataset but not for SubCategoryTableAdapter.

How can I make partial class for SubCategoryTableAdapter?

(I'd like to write my own select method because I'd like to show at least one record in my datagrid, even if there is no rows in the table. So if select statement returns 0 rows I want to just add new row with null values in it).

+1  A: 
John Saunders
A: 

I can add partial class to my TableAdapter but in it's own file (class1.cs). So this way it works.

I just wonder why I can't do it with right click -> show code on dataset designer. It doesn't matter where I click I always get this code:

namespace WebApplication1.MyMoney.DAL {


    public partial class SubCategory {

    }
}

So always just partial class for DataSet and not for TableAdapter.

John, did you type in code for partial class DimCustomerTableAdapter (including using statement) or did it autogenerate?

_simon_
It autogenerated. But it doesn't matter. Just start typing the partial class. You can have more than one class in a single file, you know.
John Saunders
I managed to make it work, thanks. But it turns out that in the end I have to use two separate files because of this bug: https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=351958
_simon_
A: 

I have the same exactly problem DataAdapter partial class wont work

ifo2