J
JDeats
I'm trying to discover where to specify attribute mapping (not sure if
that is the correct term as I'm trying to get my head around this
process) for an ObjectDataSource
My ObjectDataSource in this case is to a class called PersonData which
has Update, Insert, Delete, Select methods. Using the Update method as
an example. The Update method takes in three properties
int id, string fname, string lname, int age
Should I be following a specific naming convention on method params?
If not how does the page compiler know how what to provide to my
Insert method? I don't see a place to specify this or any explanation
on the rules of how this would be inferred by the object.
Below I'm providing a code sample of how my ObjectDataSource is
defined and a editable DataGridView that is bound to this object. On
update I get the following message:
"ObjectDataSource 'ObjectDataSource1' could not find a non-generic
method...". I assume if I could somehow tell the ObjectDataSource
where to pull/map the UpdateMethod parameters this would go away.
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
TypeName="PersonData" DeleteMethod="DeletePerson"
UpdateMethod="UpdatePerson"
InsertMethod="InsertPerson" SelectMethod="GetAllPersons">
<DeleteParameters>
<asparameter Name="id" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asparameter Name="id" Type="Int32" />
<asparameter Name="fname" Type="String" />
<asparameter Name="lname" Type="String" />
<asparameter Name="age" Type="Int32" />
</UpdateParameters>
<InsertParameters>
<asparameter Name="newid" Type="Int32" />
</InsertParameters>
</asp:ObjectDataSource>
<asp:GridView ID="GridView1" runat="server"
DataSourceID="ObjectDataSource1"
AutoGenerateColumns="False" CellPadding="4"
ForeColor="#333333"
GridLines="None">
<FooterStyle BackColor="#5D7B9D" Font-Bold="True"
ForeColor="White" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<Columns>
<asp:CommandField ShowDeleteButton="True"
ShowEditButton="True" />
<asp:BoundField DataField="PersonID"
HeaderText="PersonID"
SortExpression="PersonID" ReadOnly=false />
<asp:BoundField DataField="FName" HeaderText="FName"
SortExpression="FName" ReadOnly=false />
<asp:BoundField DataField="LName" HeaderText="LName"
SortExpression="LName" ReadOnly=false />
<asp:BoundField DataField="Age" HeaderText="Age"
SortExpression="Age" ReadOnly=false />
</Columns>
<PagerStyle BackColor="#284775" ForeColor="White"
HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True"
ForeColor="#333333" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True"
ForeColor="White" />
<EditRowStyle BackColor="#999999" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
</asp:GridView>
that is the correct term as I'm trying to get my head around this
process) for an ObjectDataSource
My ObjectDataSource in this case is to a class called PersonData which
has Update, Insert, Delete, Select methods. Using the Update method as
an example. The Update method takes in three properties
int id, string fname, string lname, int age
Should I be following a specific naming convention on method params?
If not how does the page compiler know how what to provide to my
Insert method? I don't see a place to specify this or any explanation
on the rules of how this would be inferred by the object.
Below I'm providing a code sample of how my ObjectDataSource is
defined and a editable DataGridView that is bound to this object. On
update I get the following message:
"ObjectDataSource 'ObjectDataSource1' could not find a non-generic
method...". I assume if I could somehow tell the ObjectDataSource
where to pull/map the UpdateMethod parameters this would go away.
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
TypeName="PersonData" DeleteMethod="DeletePerson"
UpdateMethod="UpdatePerson"
InsertMethod="InsertPerson" SelectMethod="GetAllPersons">
<DeleteParameters>
<asparameter Name="id" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asparameter Name="id" Type="Int32" />
<asparameter Name="fname" Type="String" />
<asparameter Name="lname" Type="String" />
<asparameter Name="age" Type="Int32" />
</UpdateParameters>
<InsertParameters>
<asparameter Name="newid" Type="Int32" />
</InsertParameters>
</asp:ObjectDataSource>
<asp:GridView ID="GridView1" runat="server"
DataSourceID="ObjectDataSource1"
AutoGenerateColumns="False" CellPadding="4"
ForeColor="#333333"
GridLines="None">
<FooterStyle BackColor="#5D7B9D" Font-Bold="True"
ForeColor="White" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<Columns>
<asp:CommandField ShowDeleteButton="True"
ShowEditButton="True" />
<asp:BoundField DataField="PersonID"
HeaderText="PersonID"
SortExpression="PersonID" ReadOnly=false />
<asp:BoundField DataField="FName" HeaderText="FName"
SortExpression="FName" ReadOnly=false />
<asp:BoundField DataField="LName" HeaderText="LName"
SortExpression="LName" ReadOnly=false />
<asp:BoundField DataField="Age" HeaderText="Age"
SortExpression="Age" ReadOnly=false />
</Columns>
<PagerStyle BackColor="#284775" ForeColor="White"
HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True"
ForeColor="#333333" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True"
ForeColor="White" />
<EditRowStyle BackColor="#999999" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
</asp:GridView>