Pass values between user controls?

G

Guest

I broke a complex page into two user controls within a container .aspx thinking I would make it more manageable

UserControl1 contains a datagrid. Upon clicking a row on this grid I want to make the container and UserControl2 aware
of the selected key ID from the code below. This ID will be used to perform a query in UserControl2 and perform and XSL Transform

Code within UserControl1
-----------------------

private void dgGrid1_ItemCommand(Object src, DataGridCommandEventArgs e

if (e.Item.ItemIndex >= 0)

//--Get the posted values from the datagrid..
dgGrid1.SelectedIndex = e.Item.ItemIndex
string sId = dgGrid1.DataKeys[e.Item.ItemIndex].ToString()



Bascially, I have these specific questions
Where and how do I make the Container and UserControl2 aware of this ID?
If so, can I get this ID in the Page_Load during the PostBack of the container? This event occurs after the page_load

Thanks, Dave
 
Joined
Aug 27, 2007
Messages
3
Reaction score
0
=?Utf-8?B?RGF2ZQ==?= said:
I broke a complex page into two user controls within a container .aspx thinking I would make it more manageable

UserControl1 contains a datagrid. Upon clicking a row on this grid I want to make the container and UserControl2 aware
of the selected key ID from the code below. This ID will be used to perform a query in UserControl2 and perform and XSL Transform

Code within UserControl1
-----------------------

private void dgGrid1_ItemCommand(Object src, DataGridCommandEventArgs e

if (e.Item.ItemIndex >= 0)

//--Get the posted values from the datagrid..
dgGrid1.SelectedIndex = e.Item.ItemIndex
string sId = dgGrid1.DataKeys[e.Item.ItemIndex].ToString()



Bascially, I have these specific questions
Where and how do I make the Container and UserControl2 aware of this ID?
If so, can I get this ID in the Page_Load during the PostBack of the container? This event occurs after the page_load

Thanks, Dave
Tanvtech:
There are so many ways to do,
In the comman event find the second control and set the value
UserControl x = (UserControl)this.Page.FindControl("UserControlOne1");
if (x != null)
{
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,021
Latest member
AkilahJaim

Latest Threads

Top