A
ayende
I've the following scenario, a web page that dispaly a GridView using
SqlDataSource define thus:
<asp:SqlDataSource ID="BoardTypes" runat="server" ConnectionString='<%$
ConnectionStrings:ConnectionString %>'
SelectCommand="SELECT BoardTypes.BoardTypeId,
BoardTypes.BoardTypeName, BoardTypes.BoardTypeDescription,
BoardTypes.ValidityEndDate, BoardTypes.ValidityStartDate,
OrganizationUnit.Name AS OrganizationalUnitName FROM BoardTypes INNER
JOIN OrganizationUnit ON OrganizationUnit.Id =
BoardTypes.OrganizationalUnitId WHERE (BoardTypes.IsCancelled =
@IsCancelled)"
InsertCommand="INSERT INTO BoardTypes(BoardTypeName,
BoardTypeDescription, ValidityStartDate, ValidityEndDate,
OrganizationalUnitId, IsCancelled) VALUES (@BoardTypeName,
@BoardTypeDescription, @ValidityStartDate, @ValidityEndDate,
@OrganizationalUnitId, 0)">
<SelectParameters>
<asparameter DefaultValue="false" Name="IsCancelled"
Type="Boolean" />
</SelectParameters>
<InsertParameters>
<asparameter Name="BoardTypeName" Type="string" />
<asparameter Name="BoardTypeDescription" Type="string"/>
<asparameter Name="ValidityStartDate" Type="datetime" />
<asparameter Name="ValidityEndDate" Type="datetime"/>
<asparameter Name="OrganizationalUnitId" Type="string"/>
</InsertParameters>
</asp:SqlDataSource>
I've a form that collects information about a new row and then post it
to the server. What I want to do is to take the values from the form
plus several other values that I get elsewhere, and insert them to the
database programmatically.
It's a dumb question, but I googled and looked in the help, and I can't
find the way to do it.
How do I pass the correct parameters? I tried InsertParameters.Add(),
but they already exist.
Another question:
Is it possible to create a page/file where I will declare all the data
sources? My goal is to be able to reuse a data source on several
classes, I can't see an immediate way to do it, though.
SqlDataSource define thus:
<asp:SqlDataSource ID="BoardTypes" runat="server" ConnectionString='<%$
ConnectionStrings:ConnectionString %>'
SelectCommand="SELECT BoardTypes.BoardTypeId,
BoardTypes.BoardTypeName, BoardTypes.BoardTypeDescription,
BoardTypes.ValidityEndDate, BoardTypes.ValidityStartDate,
OrganizationUnit.Name AS OrganizationalUnitName FROM BoardTypes INNER
JOIN OrganizationUnit ON OrganizationUnit.Id =
BoardTypes.OrganizationalUnitId WHERE (BoardTypes.IsCancelled =
@IsCancelled)"
InsertCommand="INSERT INTO BoardTypes(BoardTypeName,
BoardTypeDescription, ValidityStartDate, ValidityEndDate,
OrganizationalUnitId, IsCancelled) VALUES (@BoardTypeName,
@BoardTypeDescription, @ValidityStartDate, @ValidityEndDate,
@OrganizationalUnitId, 0)">
<SelectParameters>
<asparameter DefaultValue="false" Name="IsCancelled"
Type="Boolean" />
</SelectParameters>
<InsertParameters>
<asparameter Name="BoardTypeName" Type="string" />
<asparameter Name="BoardTypeDescription" Type="string"/>
<asparameter Name="ValidityStartDate" Type="datetime" />
<asparameter Name="ValidityEndDate" Type="datetime"/>
<asparameter Name="OrganizationalUnitId" Type="string"/>
</InsertParameters>
</asp:SqlDataSource>
I've a form that collects information about a new row and then post it
to the server. What I want to do is to take the values from the form
plus several other values that I get elsewhere, and insert them to the
database programmatically.
It's a dumb question, but I googled and looked in the help, and I can't
find the way to do it.
How do I pass the correct parameters? I tried InsertParameters.Add(),
but they already exist.
Another question:
Is it possible to create a page/file where I will declare all the data
sources? My goal is to be able to reuse a data source on several
classes, I can't see an immediate way to do it, though.