473,396 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Gridview Update via ObjectDataSource Issue

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
4 6027
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Danny W | last post by:
Hi all, I'm trying to update a record using ObjectDataSource but got the following error: The 'PhotoCount' property on the type specified by the DataObjectTypeName property in...
9
by: J055 | last post by:
Hi I'm trying to get an instance of UserLists to persist after it's been used by the GridView. I understand from the documentation that The OnObjectCreated event allows access to the instance. I...
1
by: Jim McGivney | last post by:
In VS-05 on an aspx page I have a GridView with a select item column. When the select button is pressed a DetailsView control opens with the selected record displayed. The user can now edit the...
0
by: et | last post by:
I set up a gridview to update according to a stored procedure. The parameters in the gridview <UpdateParametersare exactly the same as the parameters in the stored procedure, yet I receive the...
2
by: Olivier Matrot | last post by:
Hello, I'm using a gridview with objectdatasource and custom objects collections SELECT/INSERT/UPDATE/DELETE methods are using custom objects as parameters. This is working fine. But I have a...
0
by: troyblakely | last post by:
I have a gridview which is pulling data from a SqlDataSource, the select command queries a view and the update command is a stored procedure. I'm using a stored procedure because several tables...
0
by: tim.cavins | last post by:
I am trying a GridView for the first time and it seems to be something that should be EXTREMELY simple. I cannot get the Update or Cancel when trying to edit a row to work. When I click on the...
1
by: Steve Kershaw | last post by:
Hi, I have a problem in which I'm using a GridView with an ObjectDataSource as a data source. The problem is that when I use the ObjectDataSource UPDATE routine I must have the key column...
11
by: SAL | last post by:
Hello, I have a Gridview control (.net 2.0) that I'm having trouble getting the Update button to fire any kind of event or preforming the update. The datatable is based on a join so I don't know...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.