Hi colleagues,
how can I configure a linqdatasource in code behind. I mean I would
like to create the linqdatasource programmaticall y in the code behind
rather then dropping from the toolbox.
below is the way working but I dropped the linqdatasource control on
the aspx page then configured.
<asp:LinqDataSo urce ID="linqDSCostC enter" runat="server"
ContextTypeName ="Linq.ArtDBDat aContext"
Select="new ( BusinessUnit, Type, Division,
Status, Description1, AddressID )"
TableName="FCos tCenters">
</asp:LinqDataSou rce>
<asp:ListView ID="lvCostCente rs" runat="server"
onitemdatabound ="lvCostCenters _ItemDataBound"
DataSourceID="l inqDSCostCenter " >
<LayoutTemplate >
I would like to do this (below) ? but get some syntax errors? so I'm
not sure what the right syntax is?
does anybody knows?
LinqDataSource objDatasource = new LinqDataSource( );
Linq.ArtDBDataC ontext objDataContext = new
Linq.ArtDBDataC ontext();
objDatasource.C ontextTypeName = objDataContext;
objDatasource.T ableName = "CostCenter s";
objDatasource.S elect =
"new(BusinessUn it,Type,Divisio n,Status,Descri ption1,AddressI D)";
lvCostCenters.D ataSourceID = objDatasource;
lvCostCenters.D ataBind();
thanks mesut
how can I configure a linqdatasource in code behind. I mean I would
like to create the linqdatasource programmaticall y in the code behind
rather then dropping from the toolbox.
below is the way working but I dropped the linqdatasource control on
the aspx page then configured.
<asp:LinqDataSo urce ID="linqDSCostC enter" runat="server"
ContextTypeName ="Linq.ArtDBDat aContext"
Select="new ( BusinessUnit, Type, Division,
Status, Description1, AddressID )"
TableName="FCos tCenters">
</asp:LinqDataSou rce>
<asp:ListView ID="lvCostCente rs" runat="server"
onitemdatabound ="lvCostCenters _ItemDataBound"
DataSourceID="l inqDSCostCenter " >
<LayoutTemplate >
I would like to do this (below) ? but get some syntax errors? so I'm
not sure what the right syntax is?
does anybody knows?
LinqDataSource objDatasource = new LinqDataSource( );
Linq.ArtDBDataC ontext objDataContext = new
Linq.ArtDBDataC ontext();
objDatasource.C ontextTypeName = objDataContext;
objDatasource.T ableName = "CostCenter s";
objDatasource.S elect =
"new(BusinessUn it,Type,Divisio n,Status,Descri ption1,AddressI D)";
lvCostCenters.D ataSourceID = objDatasource;
lvCostCenters.D ataBind();
thanks mesut
Comment