Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XML to DataGrid ok - now what? (moved)

Status
Not open for further replies.

roleki

Technical User
Sep 5, 2007
22
US
I'm using VB.NET (2005) to set up a 'home page' for what will eventually be a slew of single-page reports on our corporate intranet site.

I don't want to be bogged down with a lot of table editing when I go to put a report up for consumption, so I thought I'd just have a simple DataGrid with report name/description/URL, populated by an XML file.

I've got the mechanics of bringing the XML into the DataGrid down, but I don't like the look of having the URL in a separate column.

How would I go about having a two columns, with the Report Name hyperlinked, and the Description as 'plain text'? Also, if at all possible I would like the report to load in the same window that called it, but all I know how to do is to open a new window. Any pointers on that would also be appreciated.

Here's what I have so far...

(Relevant .aspx code)

Code:
<html>
[...]
<tr >
<td align="center">
 <asp:DataGrid
   runat="server"
   ID="dgGAReports"
   SkinID="MainDG"
   AutoGenerateColumns="false">
  <Columns>
   <asp:BoundColumn 
    DataField="ReportName" 
    HeaderText="Report Name">
   </asp:BoundColumn>
   <asp:BoundColumn 
    DataField="ReportDescription"
    HeaderText="Report Description">
   </asp:BoundColumn>
   <asp:HyperLinkColumn 
    DataTextField="ReportURL" 
    DataNavigateURLFormatString="javascript:var w=window.open('details.aspx?id={0}', '', 'width=1280,height=250,left=0,top=25,directories=no,location=no,menubar=no,status=no,toolbar=no,resizable=yes,scrollbars=yes');"
    DatanavigateURLField="ReportURL"
    HeaderText="Link">
   </asp:HyperLinkColumn>
  </Columns>
 </asp:DataGrid></td>            
</tr>
[...]
</html>

And the CodeFile...


Code:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  
  Dim tGADataSet As New DataSet()
  tGADataSet.ReadXml("\\ReportServer\GAR\GAReportURLS.xml")
  dgGAReports.DataSource = tGADataSet
  
  dgGAReports.DataBind()
  lblGA.Text = "Finished Reports"
End Sub

And the XML file...

Code:
<?xml version="1.0" encoding="utf-8" ?>
<ReportList>
  <BetaReport>
    <ReportName>Summary Overview GA</ReportName>
    <ReportDescription>This is an overview of the summary information.</ReportDescription>
    <ReportURL>\\ReportServer\GAR\GASummary.aspx</ReportURL>
  </BetaReport>

  <BetaReport>
    <ReportName>Overview Summary GA</ReportName>
    <ReportDescription>This is a summary of the overview information.</ReportDescription>
    <ReportURL>\\ReportServer\GAR\GAOverview.aspx</ReportURL>
  </BetaReport>
</ReportList>

Sorry to be so verbose, I'm just kind of stuck for ideas here.
 
Also, if at all possible I would like the report to load in the same window that called it, but all I know how to do is to open a new window
Unfortunatly, the way the app is designed, it will a bit of a pain. Since each report is it's own page, then you would have to open the page in an IFrame on the containing page. There are many problems when using IFrames.
The only other way is to create only one page, have a ddl with the report names. Have the user select one and post back to the same page running the SQL tied to that report and binding to whatever. That is probably the best way to do this than having a separate page for each report.
 
use a temlpate column and create the html by hand, no need for the verbose webcontrols as this is a readonly page. i would also swap out the gridview for a repeater. gridviews are meant for modifying data.

Code:
<asp:repeater>
   <headertemplate>
      <table>
         <thead>
            <tr>
               <th>Report</th>
               <th>Details</th>
            </tr>
         </thead>
         <tbody>
   </headertemplate>
   <itemtemplate>
      <tr>
         <td><a href='<%#Eval("url")%>'><%#Eval("name of report")%></a></td>
         <td><%#Eval("text to description")%></td>
      </tr>
   </itemtemplate>
   <footertemplate>
         </tbody>
      </table>
   </footertemplate>
</asp:repeater>

as for opening up the report in the same window. you can use a simple href to navigate within the same browser.
if you want a modal popup (which is probablly what your after) check out jquery with the thickbox extension. this makes modals super easy.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Thanks for your suggestion; as it turns out, the answers was staring me in the face the whole time.

All I needed to do was set the DataTextField to "ReportName" and eliminate the DataNavigateURLFormatString setting entirely, and things are working as I wanted them to.

May not be entirely right, but it's doing what I want which is a good start for now.

Thank you again for your suggestion, though - I will try that approach at a later date.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top