Re: Gridview Update via ObjectDataSource Issue
- From: Ladislav Mrnka <LadislavMrnka@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 22 Aug 2007 14:08:02 -0700
Hi Tim,
you don't have to define parameters for controls which are connected to data
source via Bind method otherwise result set of parameters will contains them
twice. Data source is always prefilled by parameters corresponding to each
Bind call in edit/insert template. Lets try to delete them and leave only
parameters for drop down lists - I am not sure if my previous post will help
you in your case, because you are using different approach to update item
then me. I will have a look at your problem tommorow morning because I have
11:15 PM at the moment and my head is becoming out of order ...
Regards,
Ladislav
"tim.cavins@xxxxxxxxx" wrote:
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...@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
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...@xxxxxxxxx" 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...@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
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...@xxxxxxxxx" 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 -
- Follow-Ups:
- Re: Gridview Update via ObjectDataSource Issue
- From: tim . cavins
- Re: Gridview Update via ObjectDataSource Issue
- References:
- Gridview Update via ObjectDataSource Issue
- From: tim . cavins
- RE: Gridview Update via ObjectDataSource Issue
- From: Ladislav Mrnka
- Re: Gridview Update via ObjectDataSource Issue
- From: tim . cavins
- Re: Gridview Update via ObjectDataSource Issue
- From: Ladislav Mrnka
- Re: Gridview Update via ObjectDataSource Issue
- From: tim . cavins
- Gridview Update via ObjectDataSource Issue
- Prev by Date: Re: Interactive web page archiving app: need guidance
- Next by Date: Re: Gridview Update via ObjectDataSource Issue
- Previous by thread: Re: Gridview Update via ObjectDataSource Issue
- Next by thread: Re: Gridview Update via ObjectDataSource Issue
- Index(es):