473,396 Members | 1,712 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Sending a dynamic variable to a user control

Hi there! First off, let me apologize for the basic
question... I'm very new to .NET programming.

I'm building a web site using VB.NET, and am trying to
include several custom user controls. One of these user
controls handles the navigation.

This user control polls the database for the section
headers that the current user has access to. It grabs
those headers from the database, let's say 5 of them, then
proceeds to print them to the screen.

After each header, a second user control is embedded.
This user control polls the database again for all of the
individual pages under that section header the user has
access to... and then prints those to the screen one at a
time.

I've built the components, and they seem to work just
fine. My problem lies in embedding one component within
the other, and dynamically assigning one of its properties.

Here's what I'd LIKE to do:

<intranet:links runat="server" ID="myLinks" header="4" />

Where it says header="4", I'd like that 4 to be a dynamic
number. This line of code appears within a repeater, that
is bound to a dataset.

I've tried the following:

intranet:links runat="server" ID="myLinks" header="<%#
DataBinder.Eval(Container.DataItem, "ID") %>" />

But that gives me errors. What's the proper way to pass
that ID to the user control as its header property?

If you've read this far, thank you... I'm guessing that
I'm misunderstanding something VERY basic here. This
would have been simple for me to do using old school ASP,
but the .NET has got me flummoxed.

Thanks for your help!!!!!

Please email st**********@heitman.com with your responses.

Thanks,
Steve Gadlin
Jul 21 '05 #1
1 3554
One way might be to place all the code within a single control, inserting a
repeater after the section header which you can databind to the correct
data.
Alternatively, there's an "onDataBound" event which is fired each time a row
gets bound. It might be possible to use this to set the right headers.

Also, from a performance perspective you're making a lot of possibly
unnecessary database calls. Try filling two datatables with all the sections
and page titles that are available, and then using a dataview
(datatable.defaultview.rowfilter) to filter the data for each section. This
would give you two calls to the db, rather than one call for each section.

You could then either loop through each of the section headers, adding a
repeater with the right set of data for the page titles, or use the
databound event to do the same thing each time a new header is added.
--

Regards

Tim Stephenson MCSD.NET
Charted MCAD & MCSD.NET Early Achiever

"Steve Gadlin" <st**********@heitman.com> wrote in message
news:26*****************************@phx.gbl...
Hi there! First off, let me apologize for the basic
question... I'm very new to .NET programming.

I'm building a web site using VB.NET, and am trying to
include several custom user controls. One of these user
controls handles the navigation.

This user control polls the database for the section
headers that the current user has access to. It grabs
those headers from the database, let's say 5 of them, then
proceeds to print them to the screen.

After each header, a second user control is embedded.
This user control polls the database again for all of the
individual pages under that section header the user has
access to... and then prints those to the screen one at a
time.

I've built the components, and they seem to work just
fine. My problem lies in embedding one component within
the other, and dynamically assigning one of its properties.

Here's what I'd LIKE to do:

<intranet:links runat="server" ID="myLinks" header="4" />

Where it says header="4", I'd like that 4 to be a dynamic
number. This line of code appears within a repeater, that
is bound to a dataset.

I've tried the following:

intranet:links runat="server" ID="myLinks" header="<%#
DataBinder.Eval(Container.DataItem, "ID") %>" />

But that gives me errors. What's the proper way to pass
that ID to the user control as its header property?

If you've read this far, thank you... I'm guessing that
I'm misunderstanding something VERY basic here. This
would have been simple for me to do using old school ASP,
but the .NET has got me flummoxed.

Thanks for your help!!!!!

Please email st**********@heitman.com with your responses.

Thanks,
Steve Gadlin

Jul 21 '05 #2

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

Similar topics

1
by: John Hamm | last post by:
My web application dynamically creates a UserControl and saves it to a Session variable called LastControl. When a postback occurs, I simply load the LastControl and everything works great. The...
4
by: Yan Wang | last post by:
Hi!: I encounter this problem when I do some tests: I have one user control with datalist in it. The ID for datalist is "dlTest". Then in this control code behind class, I declare a protected...
0
by: Mark | last post by:
I have a "Tabbed" ASP.NET page. When a user clicks on a tab, i want the corresponsing dynamic control to be loaded. This works great except that the postbacks on that dynamically loaded control do...
4
by: spx27 | last post by:
Does anyone know the best way to handle passing a dynamic menu generated from a login from one asp.net page to another. Would it be better to recreate the menu on each page? Save the menu as a...
1
by: Steve Gadlin | last post by:
Hi there! First off, let me apologize for the basic question... I'm very new to .NET programming. I'm building a web site using VB.NET, and am trying to include several custom user controls. ...
8
by: novus | last post by:
Hi, In ASP.net 2.0 I make a control which add the same controls dynamically. In the oninit event I add the controls to the controls collection. After that the loadviewstate event fills in the...
0
by: cindy | last post by:
I have a dynamic datagrid. I have custom classes for the controls public class CreateEditItemTemplateDDL : ITemplate { DataTable dtBind; string strddlName; string strSelectedID; string...
3
by: Jeff | last post by:
Hey ASP.NET 2.0 This the ObjectDataSource in my UserControl, <asp:ObjectDataSource ID="odsMessage" runat="server" SelectMethod="ExecuteMessage" TypeName="AH.MyNetwork.BLL.Network.Message">...
9
by: Tarscher | last post by:
hi all, I have this seemingly simple problem. I have lost a lot of time on it though. When a user selects a value from a dropdownlist (static control) a dynamic control is generated. I have...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
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...
0
agi2029
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 project—planning, coding, testing,...

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.