Solved

Data grid

Posted on 2004-08-20
9
411 Views
Last Modified: 2006-11-17
Hi,
  I am using a data grid(dg1) with the columns: Name(hyperlink), age, city, country. I want to display another data grid(dg2) when the user clicks on the Name column in dg1 on the same page. The data in dg2 should display the  different transactions by that specific name clicked in dg1. Can anybody help me in this matter. Its very urgent as I am working on a dead line. Thanx in advance.
0
Comment
Question by:niki_kiran
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 8

Expert Comment

by:trevorhartman
ID: 11855097
can you post the code for dg1
0
 

Author Comment

by:niki_kiran
ID: 11855151
                             <TD>
                                    <asp:datagrid id="SearchResults" runat="server" Width="100%" BorderColor="#999999" BorderStyle="None"
                                          OnEditCommand="dg_Edit" BackColor="White" GridLines="Vertical" BorderWidth="1px" AutoGenerateColumns="False"
                                          HorizontalAlign="Justify" AllowPaging="True" OnPageIndexChanged="dg_Page" DataKeyField="CampaignID"
                                          AllowSorting="True" CellPadding="3">
                                          <SelectedItemStyle Font-Bold="True" ForeColor="White" BackColor="#004040"></SelectedItemStyle>
                                          <AlternatingItemStyle BackColor="Gainsboro"></AlternatingItemStyle>
                                          <ItemStyle ForeColor="Black" BackColor="#EEEEEE"></ItemStyle>
                                          <HeaderStyle Font-Size="8pt" Font-Names="Verdana" Font-Bold="True" HorizontalAlign="Center" ForeColor="White"
                                                VerticalAlign="Middle" BackColor="#67819E"></HeaderStyle>
                                          <FooterStyle ForeColor="Black" BackColor="#CCCCCC"></FooterStyle>
                                          <Columns>
                                                <asp:HyperLinkColumn DataNavigateUrlField="CampaignName"  DataTextField="CampaignName" HeaderText="Campaign Name"
                                                 Navigateurl=></asp:HyperLinkColumn>
                                                <asp:BoundColumn DataField="StartDate" SortExpression="StartDate" HeaderText="StartDate"></asp:BoundColumn>
                                                <asp:BoundColumn DataField="EndDate" SortExpression="EndDate" HeaderText="EndDate"></asp:BoundColumn>
                                                <asp:BoundColumn DataField="Description" SortExpression="Description" HeaderText="Description"></asp:BoundColumn>
                                                <asp:BoundColumn DataField="StatusID" HeaderText="StatusID"></asp:BoundColumn>
                                          </Columns>
                                          <PagerStyle Width="180px" VerticalAlign="Middle" NextPageText="&lt;IMG SRC=../Images/forward.gif&gt;"
                                                Font-Size="8pt" Font-Underline="True" Font-Names="Verdana" PrevPageText="&lt;IMG SRC=../Images/backward.gif&gt;"
                                                HorizontalAlign="Center" ForeColor="Navy" BackColor="#999999" Wrap="False"></PagerStyle>
                                    </asp:datagrid></TD>


This is the code with 5 columns. The column names are different from the ones i mentioned. Here the campaign name field is the hyperlink field. If I click that link it should display the transactions for that campaign in another data grid. Hope you got what i am looking for.
0
 
LVL 8

Expert Comment

by:trevorhartman
ID: 11855841
can you load the transaction details based on the CampaignID?  I noticed you set that as the DataKeyField.

create a datagrid below the current datagrid and call it dg2.  when someone clicks on hyperlinkcolumn, in your click handler just bind data to dg2 based on the DataKey of the row for the column that was clicked.

sorry it took so long, i got busy with work...

-Trevor
0
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 

Author Comment

by:niki_kiran
ID: 11855878
there is no onclick even for the hyperlink column...so how can i do something when its clicked??? there is only NavigateURL event for the hyperlink column.....
0
 
LVL 8

Accepted Solution

by:
trevorhartman earned 500 total points
ID: 11855936
use a template column instead, and create a linkbutton inside with an onclick handler
0
 

Author Comment

by:niki_kiran
ID: 11855992
hi..i think i am leaving now..will work on it from home and let u know whether it worked or not..thank you..
0
 
LVL 16

Expert Comment

by:Walter Ritzel
ID: 11856861
To solve the problem of hyperlink column doesnt have onclick event, do the following:

- in property builder, put in the field Command Name a name, like 'BINDC'.

- Create an event on dg1, the onItemCommand acessor;

- in event implementation, type this:

if (e.CommandName == "BINDC")
{
commands to bind the dg2;
}


Hope this helps,

Walter.
0
 
LVL 5

Expert Comment

by:LindzK
ID: 11857058
wont  datagrid.selectedindexchanged work for a hyperlink button ? it works for a normal button

Also, i know it's an extra link - but microsoft have a nice article on doing just what your asking

http://msdn.microsoft.com/msdnmag/issues/03/08/CuttingEdge/
0
 

Author Comment

by:niki_kiran
ID: 11882300
Thank You trevorhartman. The link button worked...sorry for getting back to u late...
0

Featured Post

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
Although a lot of people devote their energy toward marketing for specific industries, there are some basic principles that can be applied to any sector imaginable. We’ll look at four steps to take and examine how those steps were put into action fo…
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question