?
Solved

Data grid

Posted on 2004-08-20
9
Medium Priority
?
416 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This article was originally published on Monitis Blog, you can check it here . Today it’s fairly well known that high-performing websites and applications bring in more visitors, higher SEO, and ultimately more sales. By the same token, downtime…
When the s#!t hits the fan, you don’t have time to look up who’s on call, draft emails, call collaborators, or send text messages. An instant chat window is definitely the way to go, especially one like HipChat. HipChat is a true business app. An…
The viewer will learn how to count occurrences of each item in an array.
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.
Suggested Courses
Course of the Month14 days, 17 hours left to enroll

839 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