By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,201 Members | 937 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,201 IT Pros & Developers. It's quick & easy.

Filling One DataGrid Based on Selection from Another DataGrid - Both in Separate User Controls

P: n/a
Filling One DataGrid Based on Selection from Another DataGrid - Both in
Separate User Controls
Hello, I have an interesting dilemma.

I have an ASPX page with two user controls (two ASCXs). Both ASCXs have
DataGrids on them. The first user control's DataGrid is populated from our
database on page load. The DataGrid also has a Select LinkButton.

What I need is for the selected row in the first DataGrid to be used as
input to another query that dynamically fills the second DataGrid. This
second DataGrid is in the second user control. I'm having trouble doing
this. Any suggestions????

In my first user control, I have the item command event for the first
DataGrid as such:

private void DataGrid1_ItemCommand(object source, DataGridCommandEventArgs
e)
{
if (e.CommandName == "SelectMasterReport")
{
// get the selected value needed using e.Item.Cells[3].Text
// code here to populate the second DataGrid?????
}
}

Thanks in advance for any help!
Nov 19 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Ok, here is my explanation....

We have 3 parts: 1) .aspx 2). Main .ascx 3). sencondary .ascx

First thing to do (which you have done already) is load the main .ascx
(datagrid). I imagine that you are exposing the DataSource property of the
datagrid on the main .ascx control.

Next, you will have to create a bubble event within the main .ascx control
so that ItemCommand event of the datagrid will bubble up to the .aspx page.
Create properties of the data you need in order to fill the 2nd Datagrid

Now you have the event that fires in the .aspx page, capture the properties
that you set in the .ascx control and set the DataSource property of the
second .ascx control.

Seems like the only step you are missing is bubbling up the ItemCommand
event from the main .ascx control to the .aspx page......and creating and
grabbing the data from the main .ascx control and use it to set the
DataSource property of the second .ascx control.

Hope this helps !
"thegame" wrote:
Filling One DataGrid Based on Selection from Another DataGrid - Both in
Separate User Controls
Hello, I have an interesting dilemma.

I have an ASPX page with two user controls (two ASCXs). Both ASCXs have
DataGrids on them. The first user control's DataGrid is populated from our
database on page load. The DataGrid also has a Select LinkButton.

What I need is for the selected row in the first DataGrid to be used as
input to another query that dynamically fills the second DataGrid. This
second DataGrid is in the second user control. I'm having trouble doing
this. Any suggestions????

In my first user control, I have the item command event for the first
DataGrid as such:

private void DataGrid1_ItemCommand(object source, DataGridCommandEventArgs
e)
{
if (e.CommandName == "SelectMasterReport")
{
// get the selected value needed using e.Item.Cells[3].Text
// code here to populate the second DataGrid?????
}
}

Thanks in advance for any help!

Nov 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.