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 have a TotalUsers
property which is initiated when the GetUsers method is called, however it
is empty after the OnObjectCreated event runs. What am I doing wrong? Is
there a way to get the Row count from the GetUsers method (It is a
DataTable)? I don't want to call the GetUsers method twice.
Thanks for your help.
Andrew
protected void Page_Load(objec t sender, EventArgs e)
{
ObjectDataSourc e1.TypeName = "Business.UserL ists";
ObjectDataSourc e1.SelectMethod = "GetUsers";
}
protected void ObjectDataSourc e_Created(objec t sender,
ObjectDataSourc eEventArgs e)
{
UserLists users = (UserLists)e.Ob jectInstance;
Response.Write( users.TotalUser s.ToString());
} 9 11835
OK, I've found that I can use the ObjectDataSourc eStatusEventArg s class in
the OnSelected method to get the row count of the DataTable. But why do all
these events get called twice? I only have one ObjectDataSourc e and
GridView.
protected void ObjectDataSourc e_Selected(obje ct sender,
ObjectDataSourc eStatusEventArg s e)
{
//ReturnValue is a DataTable
DataTable dt = (DataTable)e.Re turnValue;
Response.Write( dt.Rows.Count.T oString());
}
"J055" <j0**@newsgroup s.nospam> wrote in message
news:%2******** ********@TK2MSF TNGP14.phx.gbl. .. 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 have a TotalUsers property which is initiated when the GetUsers method is called, however it is empty after the OnObjectCreated event runs. What am I doing wrong? Is there a way to get the Row count from the GetUsers method (It is a DataTable)? I don't want to call the GetUsers method twice.
Thanks for your help. Andrew
protected void Page_Load(objec t sender, EventArgs e) { ObjectDataSourc e1.TypeName = "Business.UserL ists"; ObjectDataSourc e1.SelectMethod = "GetUsers"; }
protected void ObjectDataSourc e_Created(objec t sender, ObjectDataSourc eEventArgs e) { UserLists users = (UserLists)e.Ob jectInstance; Response.Write( users.TotalUser s.ToString()); }
Hi J055,
Thank you for posting.
Yes, the Selected event will always be fired after the
objectdatasourc e(also available to other datasource controls) and we can
access some returned value or returned parameters there. As for the event
firing twice, it is not the expected behavior. Have you tried also register
the GridView's "Databindin g" event to see whether it is also called twice.
BTW, if convenient, would you provide some detailed code logic on the page
and your data access object class (used in objectdatasourc e control)?
Regards,
Steven Cheng
Microsoft Online Community Support
=============== =============== =============== =====
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.
Hi Steven
I've finally been able to work out what's causing events to be fired twice.
I registered the Databinding event as you suggested. The Databinding fires
twice when I add this line to the Page_Load event.
GridView1.Botto mPagerRow.CssCl ass = "break";
//It only seems to do it on Postbacks. The declarative code looks like this:
<asp:GridView ID="GridView1" runat="server" DataSourceID="O bjectDataSource 1"
OnDataBinding=" Grid_DataBindin g"
AllowSorting="T rue" AutoGenerateCol umns="False" CssClass="data"
AllowPaging="tr ue"
EnableTheming=" False" EnableViewState ="False" GridLines="None " PageSize="5"
PagerSettings-Mode="NumericFi rstLast"
PagerSettings-Position="TopAn dBottom">
<Columns>
<asp:ImageField >
</asp:ImageField>
<asp:BoundFie ld DataField="Full Name" HeaderText="Nam e"
SortExpression= "LastName" />
<asp:BoundFie ld DataField="Emai l" HeaderText="Ema il" SortExpression= "Email"
/>
<asp:BoundFie ld DataField="Last Login" HeaderText="Las t Login"
HtmlEncode="Fal se"
SortExpression= "LastLogin" />
<asp:BoundFie ld DataField="Acce ssLevel" HeaderText="Acc ess Level"
SortExpression= "AccessLeve l" />
</Columns>
</asp:GridView>
<asp:ObjectData Source ID="ObjectDataS ource1" runat="server"
SelectMethod="G etUsers"
TypeName="Empet us.Accounts.Bus iness.UserLists "></asp:ObjectDataS ource>
Is this supposed to happen? I couldn't see why but you may be able to
provide me with an explanation. I can supply you with the whole project if
that helps.
Many thanks
Andrew
"Steven Cheng[MSFT]" <st*****@online .microsoft.com> wrote in message
news:QL******** ******@TK2MSFTN GXA01.phx.gbl.. . Hi J055,
Thank you for posting.
Yes, the Selected event will always be fired after the objectdatasourc e(also available to other datasource controls) and we can access some returned value or returned parameters there. As for the event firing twice, it is not the expected behavior. Have you tried also register the GridView's "Databindin g" event to see whether it is also called twice. BTW, if convenient, would you provide some detailed code logic on the page and your data access object class (used in objectdatasourc e control)?
Regards,
Steven Cheng Microsoft Online Community Support
=============== =============== =============== =====
When responding to posts, please "Reply to Group" via your newsreader so that others may learn and benefit from your issue.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.
Hi Andrew,
Thanks for the response.
Of course, this is an unexpected behavior. However, I've ever encountered
some problem on certain events on page get fired twice, some of them are
caused by the page be posted back(or requested) twice. For example, when
there is an image tag that put a relative path reference the page's url, it
makes a GET http request to the page, thus make the page's load event
execute twice. Not sure whether this could be the case and related to your
page's code logic. I think you can try looking up the IIS log of the server
to see whether there will always occur double request entires when that
problem page get postback, if so, it is suffering the similiar problem.
Regards,
Steven Cheng
Microsoft Online Community Support
=============== =============== =============== =====
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Hi Steven
I've been using the ASP.NET development server so haven't had change to look
in the IIS logs but I have since moved the line to the Page PreRender event
which has stopped the DataBinding event firing twice...
protected void Page_PreRender( object sender, EventArgs e)
{
if (UserGrid.Allow Paging)
UserGrid.Bottom PagerRow.CssCla ss = "break";
}
Thinking about it, this may be a more appropriate place for setting these
types of properties?
Cheers
Andrew
"Steven Cheng[MSFT]" <st*****@online .microsoft.com> wrote in message
news:cg******** ******@TK2MSFTN GXA01.phx.gbl.. . Hi Andrew,
Thanks for the response.
Of course, this is an unexpected behavior. However, I've ever encountered some problem on certain events on page get fired twice, some of them are caused by the page be posted back(or requested) twice. For example, when there is an image tag that put a relative path reference the page's url, it makes a GET http request to the page, thus make the page's load event execute twice. Not sure whether this could be the case and related to your page's code logic. I think you can try looking up the IIS log of the server to see whether there will always occur double request entires when that problem page get postback, if so, it is suffering the similiar problem.
Regards,
Steven Cheng Microsoft Online Community Support
=============== =============== =============== =====
When responding to posts, please "Reply to Group" via your newsreader so that others may learn and benefit from your issue.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights. Get Secure! www.microsoft.com/security (This posting is provided "AS IS", with no warranties, and confers no rights.)
Thanks for your response Andrew,
Yes, Prerender is a good place for applying styles or other UI setting of
webserver control. However, I still feel very strange on the double
databinding behavior. Anyway, you can still have a check when hosting it in
IIS.
Regards,
Steven Cheng
Microsoft Online Community Support
=============== =============== =============== =====
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Hi Steven
I've checked this in IIS. Still get the same problem as with the development
web server.
To test I did the following:
1. Load the page - DataBinding fires once
2. Click a GridView page button - DataBinding fires twice (and for any
further postbacks)
The page didn't contain any links to external files (images, css etc). This
is the IIS log file entries for the above:
#Software: Microsoft Internet Information Services 5.1
#Version: 1.0
#Date: 2006-04-06 16:26:26
#Fields: date time c-ip cs-method cs-uri-stem sc-status
2006-04-06 16:26:26 127.0.0.1 GET /Default.aspx 200
2006-04-06 16:26:28 127.0.0.1 POST /Default.aspx 200
If I move [ GridView1.Botto mPagerRow.CssCl ass = "break"; ] to the
Page_PreRender event from the Page_Load event it doesn't fire twice when the
page buttons are clicked and I get exactly the same IIS log output.
I've also just noticed that if I put a ButtonField with an image in the
GridView the DataBinding event fires twice on postback. e.g.
<asp:ButtonFiel d ButtonType="Ima ge" ImageUrl="~/images/edit.gif" Text="Edit"
/>
I can't figure out what's happening here so would really appreciate some
suggestions on what's happening and how to resolve it.
Thanks again
Andrew
Hi Steven
I posted the response above on the 6th. I wondered if
you'd had chance to look at it and come up with any answers? I'm finding
that my pages using the GridView and ObjectDataSourc e controls seem to be
calling my Business Object method twice for no apparent reason. I clearly
can't release anything into production with this type of behaviour so I'd be
very grateful if you could let me know how to resolve this.
Cheers
Andrew
Thanks for the response Andrew,
This is indeed a strange behavior, so far I haven't found any known issue
on this. Based on my experience, this issue may require further
troubleshooting . And if you feel it urgent, you may consider contact CSS to
perform thorough troubleshooting/debugging on it. Also, you need to create
a simplified reproduce project/page on this.
Regards,
Steven Cheng
Microsoft Online Community Support
=============== =============== =============== =====
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Kjetil Klaussen |
last post by:
Hi,
I’m having some troubles trying to bind my dataset to a GridView control
through an ObjectDataSource control. The binding works fine for regular
columns in my dataset, but I can’t seem to get my expression columns to show
up in my GridView. Anybody knows any neat tricks to make this work?
Here’s a “step-by-step” to reproduce my worries:
1. Create a new “ASP.NET web site” project
|
by: David Hubbard |
last post by:
I am using a GridView to display a set of objects that have a parent-child
relationship. Each object, MyBO, has
an ID property that is used to get the children of that object.
class MyBO
{
int _id;
String _name;
|
by: jeffmagill |
last post by:
Hi Everybody,
I'm really hoping that someone can help me out because I have spent too
much time on this project already!
Basically, I have a DetailsView that handles all the Edits for a
GridView - each row has an edit button and clicking on this should
trigger that record to be loaded into the DetailsView for editing. The
problem is that the record never gets loaded into the DetailsView.
Instead, the DetailsView always and only...
|
by: syl |
last post by:
Hello
I am trying to create a "easy to use" gridview with filters (dropdownlist in
headers), sorting...and much more....
In order to do that, i prefer to use a objectdatasource (ODS) beacause
filters and sort are automaticly managed....
I would like that my own gridview (inherited from
system.web.ui.webcontrols.gridview) includes a ODS which I expose by
properties. In that way, I use this "advanced" grid view without adding on
|
by: =?Utf-8?B?QWRhciBXZXNsZXk=?= |
last post by:
Hi All,
I have a GridView inside the EditItemTemplate of a FormView. Both FormView
and GridView are data bound using an ObjectDataSource. When the FormView's
ObjectDataSource object has a SelectParameters with a SessionParameter in
the parameters collection and the object stored in the Session is a
reference type,
the DataGrid fails to enter Line Editing mode.
Is this a bug? Is there a workaround for this problem?
| |
by: newbieAl |
last post by:
I have a stored procedure in mysql and I am calling it via a method and objectdatasource. I have two select methods. One that gets a list of employees and the other that gets one specific employee by passing the employee id via a parameter.
I have two gridviews, one for displaying all employees and one for displaying one employee record. The user should be able to enter the employee id in the textbox and the gridview should display the...
|
by: newbieAl |
last post by:
I have a stored procedure in mysql and I am calling it via a method and objectdatasource. I have two select methods. One that gets a list of employees and the other that gets one specific employee by passing the employee id via a parameter.
I have two gridviews, one for displaying all employees and one for displaying one employee record. The user should be able to enter the employee id in the textbox and the gridview should display the...
|
by: Rote Rote |
last post by:
Hi Guys, I have a simple Edit,Update Gridview and i'm using
ObjectDatasource with dataset generated and TableAdapters I can do an
update no problem.
But can't get my delete to work. When i look at the parameters sent to
the store proc it all contains NULL.
I came across a solution using setting DataKeyNames but i don't have a
primary Key ID on the table.The parameters i have are
theyear,themonth,code and i want to delete based on those...
|
by: =?Utf-8?B?SnVsaWEgQg==?= |
last post by:
Hi all, this is a second post, so apologies, but I never had an answer to my
first post (several weeks ago) and I really need some help.
I'm using a .Net 2.0 Gridview which is populated using an ObjectDataSource
which calls on a method in a class. This all works fine.
The Gridview has a select button automatically generated. When the user
presses this I want to be able to take the data from the selected record and
use it. However...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |