Solved

Data grid

Posted on 2004-08-20
9
407 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
9 Comments
 
LVL 8

Expert Comment

by:trevorhartman
Comment Utility
can you post the code for dg1
0
 

Author Comment

by:niki_kiran
Comment Utility
                             <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
Comment Utility
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
 

Author Comment

by:niki_kiran
Comment Utility
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 8

Accepted Solution

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

Author Comment

by:niki_kiran
Comment Utility
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 15

Expert Comment

by:Walter Ritzel
Comment Utility
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
Comment Utility
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
Comment Utility
Thank You trevorhartman. The link button worked...sorry for getting back to u late...
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Envision that you are chipping away at another e-business site with a team of pundit developers and designers. Everything seems, by all accounts, to be going easily.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

743 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now