Solved

Data grid

Posted on 2004-08-20
9
408 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
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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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 15

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Any business that wants to seriously grow needs to keep the needs and desires of an international audience of their websites in mind. Making a website friendly to international users isn’t prohibitively expensive and can provide an incredible return…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

947 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

20 Experts available now in Live!

Get 1:1 Help Now