473,498 Members | 1,671 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 objectdatasource
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 1404
Hi,

"Nightcrawler" <th************@gmail.comwrote in message
news:11**********************@n2g2000hse.googlegro ups.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 objectdatasource
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.com

"Nightcrawler" <th************@gmail.comwrote in message
news:11**********************@n2g2000hse.googlegro ups.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 objectdatasource
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.guard.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.com

"Nightcrawler" <thomas.zale...@gmail.comwrote in message

news:11**********************@n2g2000hse.googlegro ups.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 objectdatasource
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


"Nightcrawler" <th************@gmail.comwrote in message
news:11*********************@57g2000hsv.googlegrou ps.com...
On Jul 16, 10:23 am, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guard.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.com

"Nightcrawler" <thomas.zale...@gmail.comwrote in message

news:11**********************@n2g2000hse.googlegr oups.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 objectdatasource
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
1572
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...
7
7111
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...
1
3286
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...
7
1662
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...
5
3982
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...
5
3004
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...
2
2332
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 ...
22
16882
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
10077
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...
0
7126
marktang
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,...
0
7168
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,...
0
7210
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...
1
6891
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...
0
4595
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...
0
3096
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...
0
3087
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1424
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 ...
0
293
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...

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.