jtrapat1
asked on
Hyperlinkfield report path passed in from code-behind.
I am displaying an asp:gridview of records with a linked list of results;
The first column is a hyperlinkfield of InvoiceNumber; which when the user clicks on it, launches a Reporting Services Report of details for that Invoice Number parameter;
Right now, I have the report path hard-coded and it works nice;
But I cant seem to pass the report server name/path in the code-behind.
Can this be done or do I have to use a linkbutton?
attached is my current code for the hyperlinkfield which works,
AND I am including the non-working code where I try to pass the report name path in the code-behind for the hyperlinkfield. I add a RowDataBound event to my gridview and code a function in the code-behind.
Protected Sub gvResults_RowDataBound(ByV al sender As Object, ByVal e As System.Web.UI.WebControls. GridViewRo wEventArgs ) Handles gvResults.RowDataBound
Dim strURL As String
Dim strPath As String
strURL = ConfigurationManager.AppSe ttings("Re portURL"). ToString
strPath = ConfigurationManager.AppSe ttings("Re portPath") .ToString
strPath = strURL + strPath
If e.Row.RowType = DataControlRowType.DataRow Then
Dim hl As HyperLink = TryCast(e.Row.Cells(0).Con trols(0), HyperLink)
hl.NavigateUrl = strPath
hl.NavigateUrl = "fspInvoice&rs:Command=Ren der&Invoic eNum={0}" & gvResults.DataKeyNames(e.R ow.RowInde x)(0)
End If
End Sub
Maybe I don't have the syntax correct but it seems like I have more control over the report and more properties available for the hyperlinkfield.
For example, with the hyperlinkfield, I have target="_blank" so that I can open SSRS report in a new window which helps with our application.
I dont know if that is available for the linkbutton.
thanks in advance.
john
The first column is a hyperlinkfield of InvoiceNumber; which when the user clicks on it, launches a Reporting Services Report of details for that Invoice Number parameter;
Right now, I have the report path hard-coded and it works nice;
But I cant seem to pass the report server name/path in the code-behind.
Can this be done or do I have to use a linkbutton?
attached is my current code for the hyperlinkfield which works,
AND I am including the non-working code where I try to pass the report name path in the code-behind for the hyperlinkfield. I add a RowDataBound event to my gridview and code a function in the code-behind.
Protected Sub gvResults_RowDataBound(ByV
Dim strURL As String
Dim strPath As String
strURL = ConfigurationManager.AppSe
strPath = ConfigurationManager.AppSe
strPath = strURL + strPath
If e.Row.RowType = DataControlRowType.DataRow
Dim hl As HyperLink = TryCast(e.Row.Cells(0).Con
hl.NavigateUrl = strPath
hl.NavigateUrl = "fspInvoice&rs:Command=Ren
End If
End Sub
Maybe I don't have the syntax correct but it seems like I have more control over the report and more properties available for the hyperlinkfield.
For example, with the hyperlinkfield, I have target="_blank" so that I can open SSRS report in a new window which helps with our application.
I dont know if that is available for the linkbutton.
thanks in advance.
john
working hyperlinkfield code:
<asp:HyperLinkField
HeaderText="ID"
AccessibleHeaderText="none"
ItemStyle-HorizontalAlign="Center"
ItemStyle-Wrap="False"
ItemStyle-Width="10%"
Target="_blank"
DataTextField="InvoiceNum"
DataNavigateUrlFormatString="http://allegany/reportserver?/federalsurplus/fspInvoice&rs:Command=Render&InvoiceNum={0}"
DataNavigateUrlFields="InvoiceNum"
SortExpression="InvoiceNum" >
<ItemStyle HorizontalAlign="Center" Wrap="False" Width="10%"></ItemStyle>
</asp:HyperLinkField>
ASKER
shaun kline-
thanks for the response-
I tried what you suggested but Im getting an error:
"Index was outside the bounds of the array. "
when I debug, i can mouse over and the strPath is correct;
and the DataKeyNames has the correct field name but not the value;
since this occurs when the gridview is being rendered, NOT even clicked on at this point.
In my definition for the gridview - i stripped out everything for the asp:hyperlinkfield and just added the ondataBound event to the definition like so:
OnRowDataBound="gvResults_ RowDataBou nd"
how can i fix this error?
thanks
John
thanks for the response-
I tried what you suggested but Im getting an error:
"Index was outside the bounds of the array. "
when I debug, i can mouse over and the strPath is correct;
and the DataKeyNames has the correct field name but not the value;
since this occurs when the gridview is being rendered, NOT even clicked on at this point.
In my definition for the gridview - i stripped out everything for the asp:hyperlinkfield and just added the ondataBound event to the definition like so:
OnRowDataBound="gvResults_
how can i fix this error?
thanks
John
ASKER
forgot to attach the error image-
1.gif
1.gif
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
You were absolutely right!
that worked great -
thanks
John
that worked great -
thanks
John
hl.NavigateUrl = strPath
hl.NavigateUrl = "fspInvoice&rs:Command=Ren
Instead, do:
hl.NavigateUrl = strPath & "fspInvoice&rs:Command=Ren