[System.ComponentModel.DataObject]
public class BLL
{
public BLL()
{
}
[System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select, true)]
public DataTable select()
{
DataTable D = new DataTable();
D.Columns.Add("Column1", typeof(string));
object[] Row = new object[NumberofColumns];
D.Rows.Add(Row);
return D;
}
[System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Update, true)]
public bool Update(List of parameters)
{
return true;
}
}
Select part is not a problem, I return my custom table. But how can I define list of parameters for update method while number of columns is dynamic?
As far as I see, since your DataTable is memory-based. And your dynamic DataTable can be from different kind of table in your database. So you have to reject the ObjectDataSource (because any DataSource can be applied to a fixed structure db). You have to
use SqlDataAdapter.Fill method for a DataTable, and then use SqlCommandBuilder to build automatically CRUD and if there's anything changed for any row inside the DataRow, just directly call adapter.Update(DataTable instance);
I must put some time to explore it in depth, I'm not sure if I got your meaning or not, Does
SqlDataAdapter manipulate my in memory table? There is no SQL Server backside.And, does SqlDataAdapter connect to data view controls like Gridview?
Byh the way I used DetailsView_ItemUpdating method of detailsview and it works for my case for updating my im memory table. I don't know if there may be a more standard way?
Does SqlDataAdapter manipulate my in memory table? There is no SQL Server backside.And, does SqlDataAdapter connect to data view controls like Gridview?
No. SQLDataAdapter will only fetch data contents from db's table and fill into a DataTable.
If you only wanna use a memory-based DataTable, just please define a static DataTable or a DataTable that is stored in a ViewState and you can always use that.
Ahmadi_rad
Member
76 Points
125 Posts
Custom BLL with dynamic number of columns; how to define update method?
Dec 07, 2012 07:59 PM|LINK
Hello
I have this custom BLL:
[System.ComponentModel.DataObject] public class BLL { public BLL() { } [System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select, true)] public DataTable select() { DataTable D = new DataTable(); D.Columns.Add("Column1", typeof(string)); object[] Row = new object[NumberofColumns]; D.Rows.Add(Row); return D; } [System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Update, true)] public bool Update(List of parameters) { return true; } }Select part is not a problem, I return my custom table. But how can I define list of parameters for update method while number of columns is dynamic?
Thanks
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: Custom BLL with dynamic number of columns; how to define update method?
Dec 08, 2012 09:09 AM|LINK
Hello,
As far as I see, since your DataTable is memory-based. And your dynamic DataTable can be from different kind of table in your database. So you have to reject the ObjectDataSource (because any DataSource can be applied to a fixed structure db). You have to use SqlDataAdapter.Fill method for a DataTable, and then use SqlCommandBuilder to build automatically CRUD and if there's anything changed for any row inside the DataRow, just directly call adapter.Update(DataTable instance);
Ahmadi_rad
Member
76 Points
125 Posts
Re: Custom BLL with dynamic number of columns; how to define update method?
Dec 08, 2012 07:00 PM|LINK
Thanks
I must put some time to explore it in depth, I'm not sure if I got your meaning or not, Does SqlDataAdapter manipulate my in memory table? There is no SQL Server backside. And, does SqlDataAdapter connect to data view controls like Gridview?
Byh the way I used DetailsView_ItemUpdating method of detailsview and it works for my case for updating my im memory table. I don't know if there may be a more standard way?
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: Custom BLL with dynamic number of columns; how to define update method?
Dec 09, 2012 12:43 AM|LINK
No. SQLDataAdapter will only fetch data contents from db's table and fill into a DataTable.
If you only wanna use a memory-based DataTable, just please define a static DataTable or a DataTable that is stored in a ViewState and you can always use that.
For a memory-based DataTable, that's enough;)