用broswer上传文件 [英] vie uploaded file in broswer

查看:75
本文介绍了用broswer上传文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在gridview上传了文件,现在我想查看这些文件,即当任何用户点击查看按钮时,这个documnet视图在broswer或在其他标签中打开









i uploaded file in gridview and now i want to view these files i.e when any user click view button then this documnet view in broswer or open in other tab




<asp:GridView ID="GridView1" runat="server" CellPadding="4" ForeColor="#333333"

        GridLines="None" AutoGenerateColumns="false" EmptyDataText="no files uploaded">
     
        <asp:HyperLink  runat="server" ID="lnkButton" Text="View File" />
        <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
        <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
        <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
        <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
        <EditRowStyle BackColor="#999999" />
        <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
    </asp:GridView>










<pre lang="cs">protected void FileUpload_Click(object sender, EventArgs e)
     {
         if (FileUploadControl.HasFile)
         {
             string strPath = Request.PhysicalApplicationPath + &quot;~/DocFiles/&quot; + FileUploadControl.FileName;
             FileUploadControl.SaveAs(strPath);
             lnkButton.NavigateUrl = &quot;~/DocFiles/&quot; + FileUploadControl.FileName;
         }
     }







但我在链接按钮中找到错误



当前上下文中不存在'lnkBut​​ton'这个名字



我称之为grdiview中的链接按钮(上面的网格代码)



任何帮助plzzz




but i find the error in link button

"The name 'lnkButton' does not exist in the current context "

where as i call the link button in grdiview (gridvie code above)

any help plzzz

推荐答案

你可以做类似的事情这个:

You can do something like this:
foreach(GridViewRow row in GridView1.Rows)
{
 LinkButton lb = (LinkButton) row.Cells[1].FindControl("id of button"); // Just change the index of Cells based on your requirements

} 





此信息由此提供文章:

点击


这篇关于用broswer上传文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆