September 8, 2008 at 1:42 pm
Hi. I have developed a web page where users enter an order number into a text box, hit search then details are returned to a gridview for that order. A single row is returned with columns 'Order Number' 'Product Description' etc....
Users then click a hyperlink from the navigation menu to launch a SQL report where once again they must enter the order number as a parameter to view additional information relative to the order.
What would be great is if after entering the order number in the first search the record ''Order Number' for the row returned in the gridview was a hyperlink that when clicked passed the Order Number as a parameter to the report, the report would then execute.
Now the above seems like a realistic goal, however I am no programmer!! Can you gurus offer some gentle advice 🙂
Many Thanks,
Phil.
-------------------------------------------------------------------------------------
A neutron walks into a bar. "I'd like a beer" he says. The bartender promptly serves up a beer. "How much will that be?" asks the neutron. "For you?" replies the bartender, "no charge."
Two hydrogen atoms walk into a bar. One says, 'I think I've lost an electron.' The other says 'Are you sure?' The first says, 'Yes, I'm positive... '
Tommy Cooper
September 12, 2008 at 7:43 am
Yep this is very doable.
In the columns section of your gridview control Add a column like the following...
the below example assumes the following...
your reportserver = mysvr/reportserver
Your report project = report Project
Your report = ReportName
The MyParam = the param you are trying to pass - ordernumber in this case
You want to create a column which displays your order Number and is a hyperlink that opens the report in a new window.
You could do this a bit more easily with a command button in your gridview, but I like this approach better because I want my users to actually click on the order number they want to open not a button in the next column over that says open report or some such...
<asp:TemplateField
HeaderText="Order Number"
SortExpression="MyParam">
September 12, 2008 at 7:54 am
September 12, 2008 at 10:10 am
Hi Luke. Many thanks, I will give that a try.
Thanks,
Phil.
-------------------------------------------------------------------------------------
A neutron walks into a bar. "I'd like a beer" he says. The bartender promptly serves up a beer. "How much will that be?" asks the neutron. "For you?" replies the bartender, "no charge."
Two hydrogen atoms walk into a bar. One says, 'I think I've lost an electron.' The other says 'Are you sure?' The first says, 'Yes, I'm positive... '
Tommy Cooper
September 15, 2008 at 8:03 am
Hi Luke. I am 99% there .
My code:
http://my-server/reportserver?/Dev/Folder/Route Card&rs:Command=Render&Site=0&OrderId=(OrderId)
From the gridview I selected edit column and configured as follows:
HeaderText = Route Card
Sort Expression: OrderId
NavigateURL: (my code above)
DataTextField:OrderId
The link opens the report but does not pass the value say 00012564 but instead passes string "OrderId" as written in my (OrderId).....
The web page looks as follows:
<asp:HyperLinkField DataTextField="OrderID"
HeaderText="Route Card"
NavigateUrl="http://my-server/reportserver?/Dev/Folder/Route Card&rs:Command=Render&Site=1&OrderId=(OrderId)"
SortExpression="ManufacturingOrderId">
Thanks,
Phil.
-------------------------------------------------------------------------------------
A neutron walks into a bar. "I'd like a beer" he says. The bartender promptly serves up a beer. "How much will that be?" asks the neutron. "For you?" replies the bartender, "no charge."
Two hydrogen atoms walk into a bar. One says, 'I think I've lost an electron.' The other says 'Are you sure?' The first says, 'Yes, I'm positive... '
Tommy Cooper
September 15, 2008 at 8:17 am
Try
NavigateUrl="http://my-server/reportserver?/Dev/Folder/Route Card&rs:Command=Render&Site=1&OrderId={0}"
Since you're using a hyperlinkfield you need to have the param setup to the appropriate column in your dataset. I believe that's why I went with the template column in my approach when I was originally writing my app, based on the values entered I might get more than one dataset with different column names back. For more infor on some of the differences http://codeproject.wordpress.com/2007/10/13/83/
-Luke.
September 15, 2008 at 8:30 am
Hi Luke. I tried your code. When the report renders instead of the OrderId being passed the report parameter field is populated with {0}!
If there is a better way than a hyperlink then I will try that. I used a hyperlink because that is the option I am familiar with.
Thanks,
Phil.
Update: I have changed from hyperlink to Template.
Web Page Code now reads as follows:
<asp:TemplateField HeaderText="Route Card"
SortExpression="OrderID">
Where should I add:
http://my-server/reportserver?/Dev/Folder/Route Card&rs:Command=Render&Site=0&OrderId=(OrderId)
Thanks,
Phil.
-------------------------------------------------------------------------------------
A neutron walks into a bar. "I'd like a beer" he says. The bartender promptly serves up a beer. "How much will that be?" asks the neutron. "For you?" replies the bartender, "no charge."
Two hydrogen atoms walk into a bar. One says, 'I think I've lost an electron.' The other says 'Are you sure?' The first says, 'Yes, I'm positive... '
Tommy Cooper
September 15, 2008 at 8:47 am
Check out the attached... when clicked this link should open a popup named rptwin with no toolbars etc...
Also, When you post your code make sure you preview your post first because the editor eats a good bit of the ASP code so I can't actually see what you are doing...
September 15, 2008 at 9:00 am
Luke you are a star, great work and many thanks for your patience.
One final question. Can I display alternate text in the column? i.e. instead of the OrderId can I specify 'View Route Card'
Many Thanks,
Phil.
Update. I have simply hidden the OrderID column and named the new column as desired. This will suffice.
Great work,
Phil.
-------------------------------------------------------------------------------------
A neutron walks into a bar. "I'd like a beer" he says. The bartender promptly serves up a beer. "How much will that be?" asks the neutron. "For you?" replies the bartender, "no charge."
Two hydrogen atoms walk into a bar. One says, 'I think I've lost an electron.' The other says 'Are you sure?' The first says, 'Yes, I'm positive... '
Tommy Cooper
September 15, 2008 at 9:39 am
Happy to help. Glad you finally got it sorted. For Future reference, the second Eval("OrderID") is what creates the text to be displayed. You could make that Click me or whatever else you want it to say. I prefer to make the users the click on the order number instead of a button/hyperlink etc in the next column over that says click me. Perhaps it's just me, but I feel they make a few less mistakes that way. I deal with some rather challenged users at times and anything I can do to lessen their confusion saves me lots of phone calls.
-Luke.
September 15, 2008 at 11:15 am
Ha! Ha! Some would argue that I am challenged!! On with my next project......adding a form that allows users to email faults (must be mad offering a channel for complaints!)
Once again many thanks,
Phil.
-------------------------------------------------------------------------------------
A neutron walks into a bar. "I'd like a beer" he says. The bartender promptly serves up a beer. "How much will that be?" asks the neutron. "For you?" replies the bartender, "no charge."
Two hydrogen atoms walk into a bar. One says, 'I think I've lost an electron.' The other says 'Are you sure?' The first says, 'Yes, I'm positive... '
Tommy Cooper
Viewing 11 posts - 1 through 10 (of 10 total)
You must be logged in to reply to this topic. Login to reply