Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
DotNet
acad.assignment.mngr
academic
adonet
aspnet
aspnet.announcements
aspnet.build.controls
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
clr
compactframework
component_services
datatools
distributed_apps
drawing
faqs
framework
framework.wmi
general
internationalization
interop
languages.csharp
languages.jscript
languages.vb
languages.vb.controls
languages.vb.data
languages.vb.upgrade
languages.vc
languages.vc.libraries
myservices
odbcnet
performance
remoting
scripting
sdk
security
setup
vjsharp
vsa
webservi.enhancements
webservices
windowsforms
windowsforms.controls
winforms.databinding
winforms.designtime
xml
  
 
date: Fri, 3 Jul 2009 06:27:08 -0700,    group: microsoft.public.dotnet.framework.aspnet        back       


Gridview binding twice   
All

This relates to .Net 2.0 using Visual Studio 2005.

I've got a gridview in a content page bound to an objectdatasource. The 
datasource's SelectMethod calls on a function in a sub.

I do not call the gridview databind method on page load. However I do call 
it after the user has filled out some fields (not in the gridview) and 
pressed a submit button (which saves some data to tables which the gridview 
will display the results of). This all works fine, then after the code on the 
submit button is completed, I get an error because the gridview databind 
method runs again without me calling it. Why? Can anyone tell me why the 
databind method runs a second time when I'm not calling it? How do I stop it?

The datagrid/datasource code is as follows:

<asp:GridView ID="UploadResultsGrid" runat="server" AllowPaging="True" 
AllowSorting="True" BorderColor="#D9D5D2" BorderStyle="Solid" 
BorderWidth="1pt"
        DataSourceID="UploadResultsDataSource" Font-Names="Tahoma" 
TabIndex="8">
        <RowStyle VerticalAlign="Top" />
        <HeaderStyle BackColor="#D9D5D2" ForeColor="#D7451A" 
HorizontalAlign="Left" VerticalAlign="Top" />
    </asp:GridView>
     
    <asp:ObjectDataSource ID="UploadResultsDataSource" runat="server" 
SelectMethod="FillDataGridParam"
        TypeName="RC_Web_FirestormAUCalibration.CommonUtilities">
        <SelectParameters>
            <asp:Parameter DefaultValue="GetCalibrationRecords" 
Name="spName" />
            <asp:Parameter DefaultValue="@serialnumberid" Name="ParamName" />
            <asp:Parameter DefaultValue="Integer" Name="ParamType" />
            <asp:Parameter DefaultValue="0" Name="Paramlength" />
            <asp:ControlParameter ControlID="SerialNumberTB" 
DefaultValue="Null" Name="ParamValue"
                PropertyName="Text" />
        </SelectParameters>
    </asp:ObjectDataSource>

Thanks in advance.
Julia
date: Fri, 3 Jul 2009 06:27:08 -0700   author:   Julia B

Re: Gridview binding twice   
On 3 Jul., 15:27, Julia B  wrote:
> All
>
> This relates to .Net 2.0 using Visual Studio 2005.
>
> I've got a gridview in a content page bound to an objectdatasource. The
> datasource's SelectMethod calls on a function in a sub.
>
> I do not call the gridview databind method on page load. However I do call
> it after the user has filled out some fields (not in the gridview) and
> pressed a submit button (which saves some data to tables which the gridview
> will display the results of). This all works fine, then after the code on the
> submit button is completed, I get an error because the gridview databind
> method runs again without me calling it. Why? Can anyone tell me why the
> databind method runs a second time when I'm not calling it? How do I stop it?
>
> The datagrid/datasource code is as follows:
>
> <asp:GridView ID="UploadResultsGrid" runat="server" AllowPaging="True"
> AllowSorting="True" BorderColor="#D9D5D2" BorderStyle="Solid"
> BorderWidth="1pt"
>         DataSourceID="UploadResultsDataSource" Font-Names="Tahoma"
> TabIndex="8">
>         <RowStyle VerticalAlign="Top" />
>         <HeaderStyle BackColor="#D9D5D2" ForeColor="#D7451A"
> HorizontalAlign="Left" VerticalAlign="Top" />
>     </asp:GridView>
>
>     <asp:ObjectDataSource ID="UploadResultsDataSource" runat="server"
> SelectMethod="FillDataGridParam"
>         TypeName="RC_Web_FirestormAUCalibration.CommonUtilities>         <SelectParameters>
>             <asp:Parameter DefaultValue="GetCalibrationRecords"
> Name="spName" />
>             <asp:Parameter DefaultValue="@serialnumberid" Name="ParamName" />
>             <asp:Parameter DefaultValue="Integer" Name="ParamType" />
>             <asp:Parameter DefaultValue="0" Name="Paramlength" />
>             <asp:ControlParameter ControlID="SerialNumberTB> DefaultValue="Null" Name="ParamValue"
>                 PropertyName="Text" />
>         </SelectParameters>
>     </asp:ObjectDataSource>
>
> Thanks in advance.
> Julia

What error do you get? I think you bind your grid on postback again
(when submit button is pressed)
date: Sat, 4 Jul 2009 01:30:13 -0700 (PDT)   author:   Alexey Smirnov

Re: Gridview binding twice   
Hi Alexey

The error I get is that the query string is the wrong input type. The query 
string involves some text in a text box, which would be empty on post back so 
that would make sense.

How do I stop the grid from rebinding on postback? Is that possible?

Julia

"Alexey Smirnov" wrote:

> On 3 Jul., 15:27, Julia B  wrote:
> > All
> >
> > This relates to .Net 2.0 using Visual Studio 2005.
> >
> > I've got a gridview in a content page bound to an objectdatasource. The
> > datasource's SelectMethod calls on a function in a sub.
> >
> > I do not call the gridview databind method on page load. However I do call
> > it after the user has filled out some fields (not in the gridview) and
> > pressed a submit button (which saves some data to tables which the gridview
> > will display the results of). This all works fine, then after the code on the
> > submit button is completed, I get an error because the gridview databind
> > method runs again without me calling it. Why? Can anyone tell me why the
> > databind method runs a second time when I'm not calling it? How do I stop it?
> >
> > The datagrid/datasource code is as follows:
> >
> > <asp:GridView ID="UploadResultsGrid" runat="server" AllowPaging="True"
> > AllowSorting="True" BorderColor="#D9D5D2" BorderStyle="Solid"
> > BorderWidth="1pt"
> >         DataSourceID="UploadResultsDataSource" Font-Names="Tahoma"
> > TabIndex="8">
> >         <RowStyle VerticalAlign="Top" />
> >         <HeaderStyle BackColor="#D9D5D2" ForeColor="#D7451A"
> > HorizontalAlign="Left" VerticalAlign="Top" />
> >     </asp:GridView>
> >
> >     <asp:ObjectDataSource ID="UploadResultsDataSource" runat="server"
> > SelectMethod="FillDataGridParam"
> >         TypeName="RC_Web_FirestormAUCalibration.CommonUtilities">
> >         <SelectParameters>
> >             <asp:Parameter DefaultValue="GetCalibrationRecords"
> > Name="spName" />
> >             <asp:Parameter DefaultValue="@serialnumberid" Name="ParamName" />
> >             <asp:Parameter DefaultValue="Integer" Name="ParamType" />
> >             <asp:Parameter DefaultValue="0" Name="Paramlength" />
> >             <asp:ControlParameter ControlID="SerialNumberTB"
> > DefaultValue="Null" Name="ParamValue"
> >                 PropertyName="Text" />
> >         </SelectParameters>
> >     </asp:ObjectDataSource>
> >
> > Thanks in advance.
> > Julia
> 
> What error do you get? I think you bind your grid on postback again
> (when submit button is pressed)
>
date: Mon, 6 Jul 2009 01:37:02 -0700   author:   Julia B

Re: Gridview binding twice   
Alexey, on further investigation, following your comment, I've worked out the 
steps taken and they seem very bizarre:

1 - Page opens the first time by the user (gridview fill does not happen)
2 - User selects value from a drop down list (postback happens but gridview 
fill still does not happen)
3 - User enters data into entry fields and presses the submit button - this 
is what then  happens in code:
  (a) postback happens
  (b) my code runs - ie. all the changes to the data in the back end SQL 
database
  (c) the gridview fill tries to happen and then the error occurs, I assume 
because the postback happened earlier

Why on earth does the gridview fill not happen on the first postback but 
does on the second? And how can I change this?

Thanks in advance.
Julia


"Alexey Smirnov" wrote:

> On 3 Jul., 15:27, Julia B  wrote:
> > All
> >
> > This relates to .Net 2.0 using Visual Studio 2005.
> >
> > I've got a gridview in a content page bound to an objectdatasource. The
> > datasource's SelectMethod calls on a function in a sub.
> >
> > I do not call the gridview databind method on page load. However I do call
> > it after the user has filled out some fields (not in the gridview) and
> > pressed a submit button (which saves some data to tables which the gridview
> > will display the results of). This all works fine, then after the code on the
> > submit button is completed, I get an error because the gridview databind
> > method runs again without me calling it. Why? Can anyone tell me why the
> > databind method runs a second time when I'm not calling it? How do I stop it?
> >
> > The datagrid/datasource code is as follows:
> >
> > <asp:GridView ID="UploadResultsGrid" runat="server" AllowPaging="True"
> > AllowSorting="True" BorderColor="#D9D5D2" BorderStyle="Solid"
> > BorderWidth="1pt"
> >         DataSourceID="UploadResultsDataSource" Font-Names="Tahoma"
> > TabIndex="8">
> >         <RowStyle VerticalAlign="Top" />
> >         <HeaderStyle BackColor="#D9D5D2" ForeColor="#D7451A"
> > HorizontalAlign="Left" VerticalAlign="Top" />
> >     </asp:GridView>
> >
> >     <asp:ObjectDataSource ID="UploadResultsDataSource" runat="server"
> > SelectMethod="FillDataGridParam"
> >         TypeName="RC_Web_FirestormAUCalibration.CommonUtilities">
> >         <SelectParameters>
> >             <asp:Parameter DefaultValue="GetCalibrationRecords"
> > Name="spName" />
> >             <asp:Parameter DefaultValue="@serialnumberid" Name="ParamName" />
> >             <asp:Parameter DefaultValue="Integer" Name="ParamType" />
> >             <asp:Parameter DefaultValue="0" Name="Paramlength" />
> >             <asp:ControlParameter ControlID="SerialNumberTB"
> > DefaultValue="Null" Name="ParamValue"
> >                 PropertyName="Text" />
> >         </SelectParameters>
> >     </asp:ObjectDataSource>
> >
> > Thanks in advance.
> > Julia
> 
> What error do you get? I think you bind your grid on postback again
> (when submit button is pressed)
>
date: Mon, 6 Jul 2009 03:33:01 -0700   author:   Julia B

Re: Gridview binding twice   
Hi Alexey, sorry to deluge you with responses, but I've now fixed this. I've 
changed the objectdatasource select parameter to a session variable rather 
than getting the value from a field, then it doesn't matter if the page 
postback clears the field - the session variable stays the same and the 
gridview fill works.

I'm still confused as to why the fill would automatically happen on some 
postbacks but not others and would appreciate knowing if it's possible to 
control exactly when this happens, but otherwise I'm sorted.

Thanks for your help on this.

Julia

"Alexey Smirnov" wrote:

> On 3 Jul., 15:27, Julia B  wrote:
> > All
> >
> > This relates to .Net 2.0 using Visual Studio 2005.
> >
> > I've got a gridview in a content page bound to an objectdatasource. The
> > datasource's SelectMethod calls on a function in a sub.
> >
> > I do not call the gridview databind method on page load. However I do call
> > it after the user has filled out some fields (not in the gridview) and
> > pressed a submit button (which saves some data to tables which the gridview
> > will display the results of). This all works fine, then after the code on the
> > submit button is completed, I get an error because the gridview databind
> > method runs again without me calling it. Why? Can anyone tell me why the
> > databind method runs a second time when I'm not calling it? How do I stop it?
> >
> > The datagrid/datasource code is as follows:
> >
> > <asp:GridView ID="UploadResultsGrid" runat="server" AllowPaging="True"
> > AllowSorting="True" BorderColor="#D9D5D2" BorderStyle="Solid"
> > BorderWidth="1pt"
> >         DataSourceID="UploadResultsDataSource" Font-Names="Tahoma"
> > TabIndex="8">
> >         <RowStyle VerticalAlign="Top" />
> >         <HeaderStyle BackColor="#D9D5D2" ForeColor="#D7451A"
> > HorizontalAlign="Left" VerticalAlign="Top" />
> >     </asp:GridView>
> >
> >     <asp:ObjectDataSource ID="UploadResultsDataSource" runat="server"
> > SelectMethod="FillDataGridParam"
> >         TypeName="RC_Web_FirestormAUCalibration.CommonUtilities">
> >         <SelectParameters>
> >             <asp:Parameter DefaultValue="GetCalibrationRecords"
> > Name="spName" />
> >             <asp:Parameter DefaultValue="@serialnumberid" Name="ParamName" />
> >             <asp:Parameter DefaultValue="Integer" Name="ParamType" />
> >             <asp:Parameter DefaultValue="0" Name="Paramlength" />
> >             <asp:ControlParameter ControlID="SerialNumberTB"
> > DefaultValue="Null" Name="ParamValue"
> >                 PropertyName="Text" />
> >         </SelectParameters>
> >     </asp:ObjectDataSource>
> >
> > Thanks in advance.
> > Julia
> 
> What error do you get? I think you bind your grid on postback again
> (when submit button is pressed)
>
date: Mon, 6 Jul 2009 04:01:01 -0700   author:   Julia B

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us