DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Wed, 22 Aug 2007 19:03:19 -0000,    posted on: microsoft.public.dotnet.framework.aspnet        back       

Thread Index
  1    unknown
          2    Ladislav Mrnka
                 3    Ladislav Mrnka
          4    unknown
                 5    Ladislav Mrnka
          6    unknown
          7    unknown


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
Date:Wed, 22 Aug 2007 19:03:19 -0000   Author:  

RE: Gridview Update via ObjectDataSource Issue   
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.cavins@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
> 
> 
Date:Wed, 22 Aug 2007 12:22:01 -0700   Author:  

Re: Gridview Update via ObjectDataSource Issue   
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
 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...@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 -
Date:Wed, 22 Aug 2007 19:54:35 -0000   Author:  

Re: Gridview Update via ObjectDataSource Issue   
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.cavins@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
>  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...@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 -
> 
> 
> 
Date:Wed, 22 Aug 2007 13:24:00 -0700   Author:  

Re: Gridview Update via ObjectDataSource Issue   
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
 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...@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
> >  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...@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 -
Date:Wed, 22 Aug 2007 20:40:39 -0000   Author:  

Re: Gridview Update via ObjectDataSource Issue   
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@gmail.com" 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
>  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...@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
> > >  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...@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 -
> 
> 
> 
Date:Wed, 22 Aug 2007 14:08:02 -0700   Author:  

Re: Gridview Update via ObjectDataSource Issue   
Ladislav,

Thank you very much. You have been helpful in my learning of the
objectdatasource.

In the time I posted and you posted your previous message, I tried
removing all the Update Parameters and I renamed all the Update
attributes to match the names of the drop down lists and bind values.
ie <%# Bind("prj") %> resulted in an Update attribute of prj etc.

Again, thanks! It is much appreciated.

Tim

On Aug 22, 5:08 pm, Ladislav Mrnka
 wrote:

> 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.cav...@gmail.com" 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
> >  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...@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
> > > >  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...@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 -- Hide quoted text -
>
> - Show quoted text -
Date:Wed, 22 Aug 2007 21:15:10 -0000   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us