Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

hi all...

 

In my aspx page i need to show the result files in a directory say "output". wat i do is... show these files in a datagrid which is binded dynamically. This datagrid has first column as its hyperlink column containing the filenames.so wen i click on these filenames it should be able to open these files to view. But the problem is my aspx page is in a different folder say "programs". the url on the hyperlinks points to this "programs" directory which is incorrect...it should point to "output" dir .....wat should i do to change the url so that it points to correct url of the files....... and wen i click these links it should open the file.

 

thanx

 

pavan.

Posted

Hi,

 

You should check the URL during the data binding and another option is to put the output dir in the programs and then pointing the url to the output dir is very easy. instead of making the bothe dirs on the same lavel.

Asif Raza Ashraf

Senior Software Engineer

Electronic Solutions Pakistan

Islamabad

Posted

hi..

 

thanx for replying....but i am still lost as wat to do.....i dint get u...

 

the following is the code in aspx page for the datagrid

 

------------------------------------------------------------------

<asp:datagrid id="datagrid1" runat="server" Visible="False" Font-Names="Verdana" Font-Name="Verdana" HeaderStyle-Font-Bold="True" HeaderStyle-Font-Size="12pt" AlternatingItemStyle-BackColor="#eeeeee" AutoGenerateColumns="False" Width="396px" Height="104px">

<AlternatingItemStyle BackColor="#EEEEEE"></AlternatingItemStyle>

<HeaderStyle Font-Size="12pt" Font-Bold="True" ForeColor="White" BackColor="#996600"></HeaderStyle>

<Columns>

<asp:HyperLinkColumn DataNavigateUrlField="Name" DataTextField="Name" HeaderText="File Name"></asp:HyperLinkColumn>

<asp:BoundColumn DataField="LastWriteTime" HeaderText="Last Write Time" DataFormatString="{0:d}">

<ItemStyle HorizontalAlign="Center"></ItemStyle>

</asp:BoundColumn>

<asp:BoundColumn DataField="Length" HeaderText="File Size" DataFormatString="{0:#,### bytes}">

<ItemStyle HorizontalAlign="Right"></ItemStyle>

</asp:BoundColumn>

</Columns>

</asp:datagrid>

------------------------------------------------------------------

 

and the followin is the routine which binds the data to the grid wen a button is clicked after a user selects the filenames in a radiolist.

------------------------------------------------------------------

public Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click

 

Dim dirInfo As New DirectoryInfo(Server.MapPath("../output/"))

Dim fname As String

fname = RdList1.SelectedItem.Text

datagrid1.DataSource = dirInfo.GetFiles(fname)

datagrid1.DataBind()

 

End Sub

------------------------------------------------------------------

As you can c the user selected filename in a radiolist is retrieved from the output directory....This whole code is written in a file called gridbind.aspx which is in "programs" directory......wen i run this code,say if the filename is "out.xls"......the url points "project\programs\out.xls" which is incorrect.....it should have been "project\output\out.xls"......so can u explain how should i rectify this....

 

pavan.

 

 

Hi,

 

You should check the URL during the data binding and another option is to put the output dir in the programs and then pointing the url to the output dir is very easy. instead of making the bothe dirs on the same lavel.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...