473,566 Members | 2,908 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Cumbersome on DataItemBound event

This is what I have

1. Two tables, User and Country. User contains UserId, UserName and
Country contains CountryId, and CountryName.

2. I dragged in both tables from SQL server 2005 into a dataset and
has VS 2005 create the standard Select, Update, Insert, Delete stored
procedures.

3. I have a aspx page with a datalist that has an objectdatasourc e
poiting to the User Tableadapter which simply displays the User data
on the page.

Now, for each row that is displayed I currently have to fire an
OnItemDataBound event, take the CountryId, execute a storedprocedure
to get the CountryName based, find a Label within the template for the
row and display the CountryName. So basically I execute one SP to get
the Users than an additional Stored Procedure for each row. So if I
have 10 users, I have to hit the database 11 times.

I know I can cache the country table since it is not gonna change at
all BUT what if the Country table (in theory) grew alot, then caching
would not be an option. Is there a clean and efficient way of
displaying foreign key values and still keeping the ease of strongly
typed datasets without doing timeconsuming custom coding?

Please let me know.

Thanks in advance

Jul 16 '07 #1
4 1406
Hi,

"Nightcrawl er" <th************ @gmail.comwrote in message
news:11******** **************@ n2g2000hse.goog legroups.com...
This is what I have

1. Two tables, User and Country. User contains UserId, UserName and
Country contains CountryId, and CountryName.

2. I dragged in both tables from SQL server 2005 into a dataset and
has VS 2005 create the standard Select, Update, Insert, Delete stored
procedures.

3. I have a aspx page with a datalist that has an objectdatasourc e
poiting to the User Tableadapter which simply displays the User data
on the page.

Now, for each row that is displayed I currently have to fire an
OnItemDataBound event, take the CountryId, execute a storedprocedure
to get the CountryName based, find a Label within the template for the
row and display the CountryName. So basically I execute one SP to get
the Users than an additional Stored Procedure for each row. So if I
have 10 users, I have to hit the database 11 times.
Why don't you save a copy of the country table in memory, in a datatable.
Additionally you could just return an extra colunms when you are getting the
users and add the CountryName to that dataset.

I know I can cache the country table since it is not gonna change at
all BUT what if the Country table (in theory) grew alot
In this particular case, I do not think that the Country table grows to over
200 rows, that is nothing really.
Jul 16 '07 #2
Well, I would think you wouldn't have to, because you can have an
in-memory representation of the relationship (which would make the coding in
the OnItemDataBound event easier). You mention that you have to run a
stored procedure to get the country description for each item in the row.

Instead of having a select which gets your user data, then country data,
then one stored procedure which has to be called for each row in the
country, why not just write a stored procedure which will give you the
country table and the related data, instead of calling it ten times. It
seems like that's going to be one of the big bottlenecks in all of this.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Nightcrawl er" <th************ @gmail.comwrote in message
news:11******** **************@ n2g2000hse.goog legroups.com...
This is what I have

1. Two tables, User and Country. User contains UserId, UserName and
Country contains CountryId, and CountryName.

2. I dragged in both tables from SQL server 2005 into a dataset and
has VS 2005 create the standard Select, Update, Insert, Delete stored
procedures.

3. I have a aspx page with a datalist that has an objectdatasourc e
poiting to the User Tableadapter which simply displays the User data
on the page.

Now, for each row that is displayed I currently have to fire an
OnItemDataBound event, take the CountryId, execute a storedprocedure
to get the CountryName based, find a Label within the template for the
row and display the CountryName. So basically I execute one SP to get
the Users than an additional Stored Procedure for each row. So if I
have 10 users, I have to hit the database 11 times.

I know I can cache the country table since it is not gonna change at
all BUT what if the Country table (in theory) grew alot, then caching
would not be an option. Is there a clean and efficient way of
displaying foreign key values and still keeping the ease of strongly
typed datasets without doing timeconsuming custom coding?

Please let me know.

Thanks in advance

Jul 16 '07 #3
On Jul 16, 10:23 am, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guar d.caspershouse. comwrote:
Well, I would think you wouldn't have to, because you can have an
in-memory representation of the relationship (which would make the coding in
the OnItemDataBound event easier). You mention that you have to run a
stored procedure to get the country description for each item in the row.

Instead of having a select which gets your user data, then country data,
then one stored procedure which has to be called for each row in the
country, why not just write a stored procedure which will give you the
country table and the related data, instead of calling it ten times. It
seems like that's going to be one of the big bottlenecks in all of this.

--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard .caspershouse.c om

"Nightcrawl er" <thomas.zale... @gmail.comwrote in message

news:11******** **************@ n2g2000hse.goog legroups.com...
This is what I have
1. Two tables, User and Country. User contains UserId, UserName and
Country contains CountryId, and CountryName.
2. I dragged in both tables from SQL server 2005 into a dataset and
has VS 2005 create the standard Select, Update, Insert, Delete stored
procedures.
3. I have a aspx page with a datalist that has an objectdatasourc e
poiting to the User Tableadapter which simply displays the User data
on the page.
Now, for each row that is displayed I currently have to fire an
OnItemDataBound event, take the CountryId, execute a storedprocedure
to get the CountryName based, find a Label within the template for the
row and display the CountryName. So basically I execute one SP to get
the Users than an additional Stored Procedure for each row. So if I
have 10 users, I have to hit the database 11 times.
I know I can cache the country table since it is not gonna change at
all BUT what if the Country table (in theory) grew alot, then caching
would not be an option. Is there a clean and efficient way of
displaying foreign key values and still keeping the ease of strongly
typed datasets without doing timeconsuming custom coding?
Please let me know.
Thanks in advance- Hide quoted text -

- Show quoted text -
By doing that I would have to add an extra column in my so nicely
automatically created datatable in my dataset, correct? Or I could
simply replace countryId in my User Table with say a CountryName, then
fill that datatable with one stored procedure that would do a Inner
Join with the country table.

Am I on the right track here?

Thanks

Jul 16 '07 #4


"Nightcrawl er" <th************ @gmail.comwrote in message
news:11******** *************@5 7g2000hsv.googl egroups.com...
On Jul 16, 10:23 am, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guar d.caspershouse. comwrote:
> Well, I would think you wouldn't have to, because you can have an
in-memory representation of the relationship (which would make the coding
in
the OnItemDataBound event easier). You mention that you have to run a
stored procedure to get the country description for each item in the row.

Instead of having a select which gets your user data, then country
data,
then one stored procedure which has to be called for each row in the
country, why not just write a stored procedure which will give you the
country table and the related data, instead of calling it ten times. It
seems like that's going to be one of the big bottlenecks in all of this.

--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard .caspershouse.c om

"Nightcrawle r" <thomas.zale... @gmail.comwrote in message

news:11******* *************** @n2g2000hse.goo glegroups.com.. .
This is what I have
1. Two tables, User and Country. User contains UserId, UserName and
Country contains CountryId, and CountryName.
2. I dragged in both tables from SQL server 2005 into a dataset and
has VS 2005 create the standard Select, Update, Insert, Delete stored
procedures.
3. I have a aspx page with a datalist that has an objectdatasourc e
poiting to the User Tableadapter which simply displays the User data
on the page.
Now, for each row that is displayed I currently have to fire an
OnItemDataBound event, take the CountryId, execute a storedprocedure
to get the CountryName based, find a Label within the template for the
row and display the CountryName. So basically I execute one SP to get
the Users than an additional Stored Procedure for each row. So if I
have 10 users, I have to hit the database 11 times.
I know I can cache the country table since it is not gonna change at
all BUT what if the Country table (in theory) grew alot, then caching
would not be an option. Is there a clean and efficient way of
displaying foreign key values and still keeping the ease of strongly
typed datasets without doing timeconsuming custom coding?
Please let me know.
Thanks in advance- Hide quoted text -

- Show quoted text -

By doing that I would have to add an extra column in my so nicely
automatically created datatable in my dataset, correct? Or I could
simply replace countryId in my User Table with say a CountryName, then
fill that datatable with one stored procedure that would do a Inner
Join with the country table.

Am I on the right track here?

Thanks
Why don't you create a View on the DBMS that returns all of the User fields
and the remaining Country fields that are required for display? Then, only
a single stored procedure call would be necessary and you receive all the
information in a single DataTable. Am I missing something as to why you are
not doing this?

HTH,
Mythran

Jul 16 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
1576
by: Heraklit | last post by:
Dear experts, a long time ago I spent a lot of time writing a useful program on linux/g++ with the String.h package (maybe somebody remembers this class String). Now, I am trying to reactivate this, but cannot compile it anywhere anymore, since the library is obsolete for a long time and has been removed from current g++ distributions.
7
7114
by: Dee | last post by:
I have 11 numeric fields on a form which are all inter related. When any field changes after update, all need recalculation. Each field has an after update event procedure. Each of which runs the same code in different Private Subs. Is there a way to point each private sub to just one subroutine, or do I need all of this duplicate code?
1
3293
by: slaforge | last post by:
I am trying use a repeater to process through the results of a sql query and produce a table that may or may not have multiple rows per record in the query, depending upon whether the technicians have added notes to their work. I can not get the OnItemDataBound event to fire for the repeater control. I have created a scaled-down version of what...
7
1666
by: Markus McGee | last post by:
Hi all, I have a quick question...I believe. On my web page, call it page A, I have a drop downlist with runat server enabled. When the drop downlist change event occurs it repopulates a table depending on the value selected on page A. After I redirect page A to some other page, call it page B, and use the IE Back button to change my...
5
3987
by: Christian Hvid | last post by:
What is the easiest way to get the "row object" or "item object" when a datagrid is clicked? I have web form with a datagrid. And I have an array of something called BlogEntry that I bind to the grid like this: private void Page_Load(object sender, System.EventArgs e) { BlogEntry entries = DataLayer.GetAllBlogEntries();...
5
3005
by: CJ Taylor | last post by:
Hey all, This is probably a dumb question, but still feeling a little strange from Labor day festiviities. Anyways, I want a shared sub, at least something that is easy to call from any one of my classes within the scope of my project (or that which inherits/imports this class). Basically, want them to be able to call a sub defined as
2
2341
by: Garth | last post by:
I ran into a small issue and I found a solution however it is cumbersome to use. The problem and solution is describe within the MSDN article http://msdn2.microsoft.com/en-us/library/ms171728(d=ide).aspx I would like to create one subroutine for all my textboxes and not one for each textbox, given the sample subroutine below, how can I add...
22
16898
by: dvestal | last post by:
Suppose I have this: class C { public delegate void MyEventHandler(); public event MyEventHandler MyEvent; public void foo() { MyEvent(); // NullReferenceException? } }
3
10089
by: beaker | last post by:
Hello, I have a DataGridView and I want to handle the CellContentDoubleClick event. No problem so far, but when I double click on a cell the CellContentDoubleClick event only fires if I double click over text, and not over any 'white space' in the cell. How do I get the event to fire when I click anywhere in the cell? (I have...
0
7584
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...
0
7893
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8109
jinu1996
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...
0
7953
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5485
isladogs
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...
0
5213
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...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2085
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
0
926
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.