By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,888 Members | 1,540 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,888 IT Pros & Developers. It's quick & easy.

Gridview Update via ObjectDataSource Issue

P: n/a
I have a GridView populated by an ObjectDataSource.

I am having issues passing the parameters to the objectdatasource. I
have verified that the method is being called but none of the
parameters are being populated. Integers are being passed as 0 and
strings are empty regardless of what I changed them to in Edit mode on
the GridView.

My object method to perform the update:

Public Shared Sub Update(ByVal intID As Integer, ByVal intType As
Integer, ByVal intModel As Integer, ByVal intSA As Integer, ByVal
strSer As String, ByVal strPO As String, ByVal strPrj As String, ByVal
strRV As String, ByVal intQty As Integer, ByVal strComment As String)

....
End Sub
Here is my ObjectDataSource:

<asp:ObjectDataSource ID="odsSA" runat="server" SelectMethod="GetSA"
TypeName="App_BL.SA" UpdateMethod="Update">
<SelectParameters>
....
</SelectParameters>
<UpdateParameters>
<asp:FormParameter Name="intID" FormField="hdnSAID" Type="Int32" />
<asp:FormParameter Name="intType" FormField="drpEditSAType"
Type="Int32" />
<asp:FormParameter Name="intModel" FormField="drpEditModel"
Type="Int32" />
<asp:FormParameter Name="intSA" FormField="drpEditSA" Type="Int32" />
<asp:FormParameter Name="strSer" FormField="txtEditSASer"
Type="String" />
<asp:FormParameter Name="strPO" FormField="txtEditPO" Type="String" />
<asp:FormParameter Name="strPrj" FormField="txtEditPrj" Type="String" /
>
<asp:FormParameter Name="strRV" FormField="txtEditRV" Type="String" />
<asp:FormParameter Name="intQty" FormField="txtEditQty" Type="Int32" /
>
<asp:FormParameter Name="strComment" FormField="txtEditSAComment"
Type="String" />
</UpdateParameters>
</asp:ObjectDataSource>

My GridView Edit Template:

<tr>
<td><input type="hidden" id="hdnSAID" runat="server" value='<%#
Eval("id") %>' /><asp:DropDownList ID="drpEditSAType" runat="server" /
></td>
<td><asp:DropDownList ID="drpEditModel" runat="server" /></td>

<td><asp:DropDownList ID="drpEditSA" runat="server" /></td>

<td><asp:TextBox ID="txtEditSASer" runat="server" Text='<%#
Eval("saser") %>' /></td>

<td><asp:TextBox ID="txtEditPO" runat="server" Text='<%# Eval("saPO")
%>' /></td>

<td><asp:TextBox ID="txtEditPrj" runat="server" Text='<%# Eval("prj")
%>' /></td>

<td><asp:TextBox ID="txtEditRV" runat="server" Text='<%# Eval("RV")
%>' /></td>

<td><asp:TextBox ID="txtEditQty" runat="server" Text='<%# Eval("qty")
%>' /></td>

<td><asp:TextBox ID="txtEditSAComment" runat="server" Text='<%#
Eval("comment") %>' TextMode="MultiLine" Rows="3" Columns="20" /></td>

</tr>

What needs to be done so I can have the values from the GridView
populate my Update method?

If any other info is needed, please let me know.

Tim

Aug 22 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Hi Tim,
if you want to update your values from grid view you have to use to way
databinding verb. Eval is just one way - it will only populate your gridview
from data source. Try to use Bind instead like
<asp:TextBox ID="txtEditSASer" runat="server" Text='<%#Bind("saser") %>' />

Regards,
Ladislav

"ti********@gmail.com" wrote:
I have a GridView populated by an ObjectDataSource.

I am having issues passing the parameters to the objectdatasource. I
have verified that the method is being called but none of the
parameters are being populated. Integers are being passed as 0 and
strings are empty regardless of what I changed them to in Edit mode on
the GridView.

My object method to perform the update:

Public Shared Sub Update(ByVal intID As Integer, ByVal intType As
Integer, ByVal intModel As Integer, ByVal intSA As Integer, ByVal
strSer As String, ByVal strPO As String, ByVal strPrj As String, ByVal
strRV As String, ByVal intQty As Integer, ByVal strComment As String)

....
End Sub
Here is my ObjectDataSource:

<asp:ObjectDataSource ID="odsSA" runat="server" SelectMethod="GetSA"
TypeName="App_BL.SA" UpdateMethod="Update">
<SelectParameters>
....
</SelectParameters>
<UpdateParameters>
<asp:FormParameter Name="intID" FormField="hdnSAID" Type="Int32" />
<asp:FormParameter Name="intType" FormField="drpEditSAType"
Type="Int32" />
<asp:FormParameter Name="intModel" FormField="drpEditModel"
Type="Int32" />
<asp:FormParameter Name="intSA" FormField="drpEditSA" Type="Int32" />
<asp:FormParameter Name="strSer" FormField="txtEditSASer"
Type="String" />
<asp:FormParameter Name="strPO" FormField="txtEditPO" Type="String" />
<asp:FormParameter Name="strPrj" FormField="txtEditPrj" Type="String" /
<asp:FormParameter Name="strRV" FormField="txtEditRV" Type="String" />
<asp:FormParameter Name="intQty" FormField="txtEditQty" Type="Int32" /
<asp:FormParameter Name="strComment" FormField="txtEditSAComment"
Type="String" />
</UpdateParameters>
</asp:ObjectDataSource>

My GridView Edit Template:

<tr>
<td><input type="hidden" id="hdnSAID" runat="server" value='<%#
Eval("id") %>' /><asp:DropDownList ID="drpEditSAType" runat="server" /
</td>

<td><asp:DropDownList ID="drpEditModel" runat="server" /></td>

<td><asp:DropDownList ID="drpEditSA" runat="server" /></td>

<td><asp:TextBox ID="txtEditSASer" runat="server" Text='<%#
Eval("saser") %>' /></td>

<td><asp:TextBox ID="txtEditPO" runat="server" Text='<%# Eval("saPO")
%>' /></td>

<td><asp:TextBox ID="txtEditPrj" runat="server" Text='<%# Eval("prj")
%>' /></td>

<td><asp:TextBox ID="txtEditRV" runat="server" Text='<%# Eval("RV")
%>' /></td>

<td><asp:TextBox ID="txtEditQty" runat="server" Text='<%# Eval("qty")
%>' /></td>

<td><asp:TextBox ID="txtEditSAComment" runat="server" Text='<%#
Eval("comment") %>' TextMode="MultiLine" Rows="3" Columns="20" /></td>

</tr>

What needs to be done so I can have the values from the GridView
populate my Update method?

If any other info is needed, please let me know.

Tim

Aug 22 '07 #2

P: n/a
Ladislav,

I changed the Eval's to Bind for the Text Boxes. I then re-ran my
application and am now getting the following error when I click the
Update link:

ObjectDataSource 'odsSA' could not find a non-generic method 'Update'
that has parameters: intID, intType, intModel, intSA, strSer, strPO,
strPrj, strRV, intQty, strComment, id, then it lists the field names
that have Bind("") in them but does not list my drop down lists.

Any insight on this?

Tim

On Aug 22, 3:22 pm, Ladislav Mrnka
<LadislavMr...@discussions.microsoft.comwrote:
Hi Tim,
if you want to update your values from grid view you have to use to way
databinding verb. Eval is just one way - it will only populate your gridview
from data source. Try to use Bind instead like
<asp:TextBox ID="txtEditSASer" runat="server" Text='<%#Bind("saser") %>' />

Regards,
Ladislav

"tim.cav...@gmail.com" wrote:
I have a GridView populated by anObjectDataSource.
I am having issues passing the parameters to theobjectdatasource. I
have verified that the method is being called but none of the
parameters are being populated. Integers are being passed as 0 and
strings are empty regardless of what I changed them to in Edit mode on
the GridView.
My object method to perform the update:
Public Shared Sub Update(ByVal intID As Integer, ByVal intType As
Integer, ByVal intModel As Integer, ByVal intSA As Integer, ByVal
strSer As String, ByVal strPO As String, ByVal strPrj As String, ByVal
strRV As String, ByVal intQty As Integer, ByVal strComment As String)
....
End Sub
Here is myObjectDataSource:
<asp:ObjectDataSourceID="odsSA" runat="server" SelectMethod="GetSA"
TypeName="App_BL.SA" UpdateMethod="Update">
<SelectParameters>
....
</SelectParameters>
<UpdateParameters>
<asp:FormParameter Name="intID" FormField="hdnSAID" Type="Int32" />
<asp:FormParameter Name="intType" FormField="drpEditSAType"
Type="Int32" />
<asp:FormParameter Name="intModel" FormField="drpEditModel"
Type="Int32" />
<asp:FormParameter Name="intSA" FormField="drpEditSA" Type="Int32" />
<asp:FormParameter Name="strSer" FormField="txtEditSASer"
Type="String" />
<asp:FormParameter Name="strPO" FormField="txtEditPO" Type="String" />
<asp:FormParameter Name="strPrj" FormField="txtEditPrj" Type="String" /
<asp:FormParameter Name="strRV" FormField="txtEditRV" Type="String" />
<asp:FormParameter Name="intQty" FormField="txtEditQty" Type="Int32" /
<asp:FormParameter Name="strComment" FormField="txtEditSAComment"
Type="String" />
</UpdateParameters>
</asp:ObjectDataSource>
My GridView Edit Template:
<tr>
<td><input type="hidden" id="hdnSAID" runat="server" value='<%#
Eval("id") %>' /><asp:DropDownList ID="drpEditSAType" runat="server" /
></td>
<td><asp:DropDownList ID="drpEditModel" runat="server" /></td>
<td><asp:DropDownList ID="drpEditSA" runat="server" /></td>
<td><asp:TextBox ID="txtEditSASer" runat="server" Text='<%#
Eval("saser") %>' /></td>
<td><asp:TextBox ID="txtEditPO" runat="server" Text='<%# Eval("saPO")
%>' /></td>
<td><asp:TextBox ID="txtEditPrj" runat="server" Text='<%# Eval("prj")
%>' /></td>
<td><asp:TextBox ID="txtEditRV" runat="server" Text='<%# Eval("RV")
%>' /></td>
<td><asp:TextBox ID="txtEditQty" runat="server" Text='<%# Eval("qty")
%>' /></td>
<td><asp:TextBox ID="txtEditSAComment" runat="server" Text='<%#
Eval("comment") %>' TextMode="MultiLine" Rows="3" Columns="20" /></td>
</tr>
What needs to be done so I can have the values from the GridView
populate my Update method?
If any other info is needed, please let me know.
Tim- Hide quoted text -

- Show quoted text -

Aug 22 '07 #3

P: n/a
Hi Tim,
I am sorry I didn't notice drop down lists before. Yes, drop down lists are
problem. You have to handle them in different way. You can add handler for
RowUpdating event to your GridView. There you can add selected values from
your drop down lists to NewValues collection.

protected void myGrid_OnRowUpdating(object sender, GridViewUpdateEventArgs e)
{
e.NewValues.Add("intSA", GetSelectedValueFromMyDropDownList());
}

NewValues contains all values bind in your row for updating. I'm not sure if
I'm using right identifier for param. The best way how to check it is to stop
execution in this method and check collection in debugger - then use similar
identifiers like those used in collection for your text boxes.

I have used this technique several times but always with FormView and with
ObjectDataSource using DataObjectTypeName parameter = my update methods were
static with single parameter. I hope this will work but probably you will
have to play little bit with it.

Regards,
Ladislav

"ti********@gmail.com" wrote:
Ladislav,

I changed the Eval's to Bind for the Text Boxes. I then re-ran my
application and am now getting the following error when I click the
Update link:

ObjectDataSource 'odsSA' could not find a non-generic method 'Update'
that has parameters: intID, intType, intModel, intSA, strSer, strPO,
strPrj, strRV, intQty, strComment, id, then it lists the field names
that have Bind("") in them but does not list my drop down lists.

Any insight on this?

Tim

On Aug 22, 3:22 pm, Ladislav Mrnka
<LadislavMr...@discussions.microsoft.comwrote:
Hi Tim,
if you want to update your values from grid view you have to use to way
databinding verb. Eval is just one way - it will only populate your gridview
from data source. Try to use Bind instead like
<asp:TextBox ID="txtEditSASer" runat="server" Text='<%#Bind("saser") %>' />

Regards,
Ladislav

"tim.cav...@gmail.com" wrote:
I have a GridView populated by anObjectDataSource.
I am having issues passing the parameters to theobjectdatasource. I
have verified that the method is being called but none of the
parameters are being populated. Integers are being passed as 0 and
strings are empty regardless of what I changed them to in Edit mode on
the GridView.
My object method to perform the update:
Public Shared Sub Update(ByVal intID As Integer, ByVal intType As
Integer, ByVal intModel As Integer, ByVal intSA As Integer, ByVal
strSer As String, ByVal strPO As String, ByVal strPrj As String, ByVal
strRV As String, ByVal intQty As Integer, ByVal strComment As String)
....
End Sub
Here is myObjectDataSource:
<asp:ObjectDataSourceID="odsSA" runat="server" SelectMethod="GetSA"
TypeName="App_BL.SA" UpdateMethod="Update">
<SelectParameters>
....
</SelectParameters>
<UpdateParameters>
<asp:FormParameter Name="intID" FormField="hdnSAID" Type="Int32" />
<asp:FormParameter Name="intType" FormField="drpEditSAType"
Type="Int32" />
<asp:FormParameter Name="intModel" FormField="drpEditModel"
Type="Int32" />
<asp:FormParameter Name="intSA" FormField="drpEditSA" Type="Int32" />
<asp:FormParameter Name="strSer" FormField="txtEditSASer"
Type="String" />
<asp:FormParameter Name="strPO" FormField="txtEditPO" Type="String" />
<asp:FormParameter Name="strPrj" FormField="txtEditPrj" Type="String" /
<asp:FormParameter Name="strRV" FormField="txtEditRV" Type="String" />
<asp:FormParameter Name="intQty" FormField="txtEditQty" Type="Int32" /
<asp:FormParameter Name="strComment" FormField="txtEditSAComment"
Type="String" />
</UpdateParameters>
</asp:ObjectDataSource>
My GridView Edit Template:
<tr>
<td><input type="hidden" id="hdnSAID" runat="server" value='<%#
Eval("id") %>' /><asp:DropDownList ID="drpEditSAType" runat="server" /
</td>
<td><asp:DropDownList ID="drpEditModel" runat="server" /></td>
<td><asp:DropDownList ID="drpEditSA" runat="server" /></td>
<td><asp:TextBox ID="txtEditSASer" runat="server" Text='<%#
Eval("saser") %>' /></td>
<td><asp:TextBox ID="txtEditPO" runat="server" Text='<%# Eval("saPO")
%>' /></td>
<td><asp:TextBox ID="txtEditPrj" runat="server" Text='<%# Eval("prj")
%>' /></td>
<td><asp:TextBox ID="txtEditRV" runat="server" Text='<%# Eval("RV")
%>' /></td>
<td><asp:TextBox ID="txtEditQty" runat="server" Text='<%# Eval("qty")
%>' /></td>
<td><asp:TextBox ID="txtEditSAComment" runat="server" Text='<%#
Eval("comment") %>' TextMode="MultiLine" Rows="3" Columns="20" /></td>
</tr>
What needs to be done so I can have the values from the GridView
populate my Update method?
If any other info is needed, please let me know.
Tim- Hide quoted text -
- Show quoted text -


Aug 22 '07 #4

P: n/a
Ladislav,

I have added my dropdownlists into the RowEditing method. However, I'm
still getting the same non-generic error message when I click the
update button.

It is checking for an Update method that contains the fields I listed
as parameters plus all the TextBoxes that appear in the Edit mode of
the gridview. Why is the objectdatasource adding these and how do I
get around it?

Tim

On Aug 22, 4:24 pm, Ladislav Mrnka
<LadislavMr...@discussions.microsoft.comwrote:
Hi Tim,
I am sorry I didn't notice drop down lists before. Yes, drop down lists are
problem. You have to handle them in different way. You can add handler for
RowUpdating event to your GridView. There you can add selected values from
your drop down lists to NewValues collection.

protected void myGrid_OnRowUpdating(object sender, GridViewUpdateEventArgs e)
{
e.NewValues.Add("intSA", GetSelectedValueFromMyDropDownList());

}

NewValues contains all values bind in your row for updating. I'm not sure if
I'm using right identifier for param. The best way how to check it is to stop
execution in this method and check collection in debugger - then use similar
identifiers like those used in collection for your text boxes.

I have used this technique several times but always with FormView and with
ObjectDataSource using DataObjectTypeName parameter = my update methods were
static with single parameter. I hope this will work but probably you will
have to play little bit with it.

Regards,
Ladislav

"tim.cav...@gmail.com" wrote:
Ladislav,
I changed the Eval's to Bind for the Text Boxes. I then re-ran my
application and am now getting the following error when I click the
Update link:
ObjectDataSource 'odsSA' could not find a non-generic method 'Update'
that has parameters: intID, intType, intModel, intSA, strSer, strPO,
strPrj, strRV, intQty, strComment, id, then it lists the field names
that have Bind("") in them but does not list my drop down lists.
Any insight on this?
Tim
On Aug 22, 3:22 pm, Ladislav Mrnka
<LadislavMr...@discussions.microsoft.comwrote:
Hi Tim,
if you want to update your values from grid view you have to use to way
databinding verb. Eval is just one way - it will only populate your gridview
from data source. Try to use Bind instead like
<asp:TextBox ID="txtEditSASer" runat="server" Text='<%#Bind("saser") %>' />
Regards,
Ladislav
"tim.cav...@gmail.com" wrote:
I have a GridView populated by anObjectDataSource.
I am having issues passing the parameters to theobjectdatasource. I
have verified that the method is being called but none of the
parameters are being populated. Integers are being passed as 0 and
strings are empty regardless of what I changed them to in Edit mode on
the GridView.
My object method to perform the update:
Public Shared Sub Update(ByVal intID As Integer, ByVal intType As
Integer, ByVal intModel As Integer, ByVal intSA As Integer, ByVal
strSer As String, ByVal strPO As String, ByVal strPrj As String, ByVal
strRV As String, ByVal intQty As Integer, ByVal strComment As String)
....
End Sub
Here is myObjectDataSource:
<asp:ObjectDataSourceID="odsSA" runat="server" SelectMethod="GetSA"
TypeName="App_BL.SA" UpdateMethod="Update">
<SelectParameters>
....
</SelectParameters>
<UpdateParameters>
<asp:FormParameter Name="intID" FormField="hdnSAID" Type="Int32" />
<asp:FormParameter Name="intType" FormField="drpEditSAType"
Type="Int32" />
<asp:FormParameter Name="intModel" FormField="drpEditModel"
Type="Int32" />
<asp:FormParameter Name="intSA" FormField="drpEditSA" Type="Int32" />
<asp:FormParameter Name="strSer" FormField="txtEditSASer"
Type="String" />
<asp:FormParameter Name="strPO" FormField="txtEditPO" Type="String" />
<asp:FormParameter Name="strPrj" FormField="txtEditPrj" Type="String" /
<asp:FormParameter Name="strRV" FormField="txtEditRV" Type="String" />
<asp:FormParameter Name="intQty" FormField="txtEditQty" Type="Int32" /
<asp:FormParameter Name="strComment" FormField="txtEditSAComment"
Type="String" />
</UpdateParameters>
</asp:ObjectDataSource>
My GridView Edit Template:
<tr>
<td><input type="hidden" id="hdnSAID" runat="server" value='<%#
Eval("id") %>' /><asp:DropDownList ID="drpEditSAType" runat="server" /
></td>
<td><asp:DropDownList ID="drpEditModel" runat="server" /></td>
<td><asp:DropDownList ID="drpEditSA" runat="server" /></td>
<td><asp:TextBox ID="txtEditSASer" runat="server" Text='<%#
Eval("saser") %>' /></td>
<td><asp:TextBox ID="txtEditPO" runat="server" Text='<%# Eval("saPO")
%>' /></td>
<td><asp:TextBox ID="txtEditPrj" runat="server" Text='<%# Eval("prj")
%>' /></td>
<td><asp:TextBox ID="txtEditRV" runat="server" Text='<%# Eval("RV")
%>' /></td>
<td><asp:TextBox ID="txtEditQty" runat="server" Text='<%# Eval("qty")
%>' /></td>
<td><asp:TextBox ID="txtEditSAComment" runat="server" Text='<%#
Eval("comment") %>' TextMode="MultiLine" Rows="3" Columns="20" /></td>
</tr>
What needs to be done so I can have the values from the GridView
populate my Update method?
If any other info is needed, please let me know.
Tim- Hide quoted text -
- Show quoted text -- Hide quoted text -

- Show quoted text -

Aug 22 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.