R
rgparkins
So, I've bitten the bullet and am converting some of my asp.net 1.1
sites to asp.net 2.0, now after many issues I have come to a stop with
the objectdatasource and gridviews and maybe someone can help!
I have update, add adapter calls on the objectdatasource working well,
however I have an issue with the delete call.
In ASP.NET 2.0 I see that invisible columns are now no longer sent
across in viewstate (something about security) and this was my first
issue when converting, so I read a blog that the way to get round this
is to store the values in the datakeynames property of the grid, ok so
far!
In my gridview I have some dropdown lists in the edittemplate and
checkboxes which DONT store value information therefore things like
"isenabled" column from the database which will be displayed as a
checkbox I store in the datakeynames of the gridview which works fine
apart from when I call the delete method on a row.
My delete method has one parameter, the id of the row and this is
sufficient to delete, BUT because I have placed 3 other columns in the
datakeynames it now requires me to place these columns as parameters
in the delete method!!
I know I can do a workaround of having invisible labels in the
template columns or just create the method with these parameters but
is that really a solution?
Am I missing something, There is only 1 delete parameter in my
objectdatasource markup (see below) so why is it saying I need 4
parameters which cunningly enough is equal to the datakeynames I have
set
If anyone can help or shed some light I would be grateful
Many thanks
Richard
<asp:GridView ID="GridViewDetail" DataSourceID="ObjectDataSource1"
runat="server" AutoGenerateColumns="False"
DataKeyNames="PId,PSpecial,PBillable,PStatus" PageSize="100"
OnRowDataBound="GridViewDetail_RowDataBound" ShowFooter="True"
OnRowCommand="GridViewDetail_RowCommand"
OnRowUpdating="GridViewDetail_RowUpdating"
CssClass="subcostsfullspan">
<Columns>
<Columns.....>
</Columns>
</asp:GridView>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
SelectMethod="GetProducts"
TypeName="xxx.LifeStyleSystem.BusinessLayer.Search.ProductManager"
UpdateMethod="UpdateProduct" DeleteMethod="DeleteProduct">
<UpdateParameters>
<asparameter Name="PId" Type="Int64" />
<asparameter Name="PCostString" Type="String" />
<asparameter Name="PDescription" Type="String" />
<asparameter Name="PGross" Type="Decimal" />
<asparameter Name="PSpecial" Type="Boolean" />
<asparameter Name="PStatus" Type="Int32" />
<asparameter Name="PBillable" Type="Boolean" />
</UpdateParameters>
<DeleteParameters>
<asparameter Name="PdId" Type="Int64" />
</DeleteParameters>
</asp:ObjectDataSource>
sites to asp.net 2.0, now after many issues I have come to a stop with
the objectdatasource and gridviews and maybe someone can help!
I have update, add adapter calls on the objectdatasource working well,
however I have an issue with the delete call.
In ASP.NET 2.0 I see that invisible columns are now no longer sent
across in viewstate (something about security) and this was my first
issue when converting, so I read a blog that the way to get round this
is to store the values in the datakeynames property of the grid, ok so
far!
In my gridview I have some dropdown lists in the edittemplate and
checkboxes which DONT store value information therefore things like
"isenabled" column from the database which will be displayed as a
checkbox I store in the datakeynames of the gridview which works fine
apart from when I call the delete method on a row.
My delete method has one parameter, the id of the row and this is
sufficient to delete, BUT because I have placed 3 other columns in the
datakeynames it now requires me to place these columns as parameters
in the delete method!!
I know I can do a workaround of having invisible labels in the
template columns or just create the method with these parameters but
is that really a solution?
Am I missing something, There is only 1 delete parameter in my
objectdatasource markup (see below) so why is it saying I need 4
parameters which cunningly enough is equal to the datakeynames I have
set
If anyone can help or shed some light I would be grateful
Many thanks
Richard
<asp:GridView ID="GridViewDetail" DataSourceID="ObjectDataSource1"
runat="server" AutoGenerateColumns="False"
DataKeyNames="PId,PSpecial,PBillable,PStatus" PageSize="100"
OnRowDataBound="GridViewDetail_RowDataBound" ShowFooter="True"
OnRowCommand="GridViewDetail_RowCommand"
OnRowUpdating="GridViewDetail_RowUpdating"
CssClass="subcostsfullspan">
<Columns>
<Columns.....>
</Columns>
</asp:GridView>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
SelectMethod="GetProducts"
TypeName="xxx.LifeStyleSystem.BusinessLayer.Search.ProductManager"
UpdateMethod="UpdateProduct" DeleteMethod="DeleteProduct">
<UpdateParameters>
<asparameter Name="PId" Type="Int64" />
<asparameter Name="PCostString" Type="String" />
<asparameter Name="PDescription" Type="String" />
<asparameter Name="PGross" Type="Decimal" />
<asparameter Name="PSpecial" Type="Boolean" />
<asparameter Name="PStatus" Type="Int32" />
<asparameter Name="PBillable" Type="Boolean" />
</UpdateParameters>
<DeleteParameters>
<asparameter Name="PdId" Type="Int64" />
</DeleteParameters>
</asp:ObjectDataSource>