我想使用超链接从表中检索数据到打开文件 [英] i want to retrive data from table to open file using hyperlink

查看:74
本文介绍了我想使用超链接从表中检索数据到打开文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有3列ID,FL_Name,通知表中的数据。现在我从数据库中检索后显示了Fl_Name列作为超链接。现在我想通过点击该链接来检索存储文件路径的数据列,即。该文件应该打开。

我的代码如下:

i have 3 column ID, FL_Name, Data in Notification table. now i have display Fl_Name column as a hyperlink after retrieving it from database. now i want to retrive Data column which stores a File path by click on that link ie. the file should get opened.
my code is as follow:

<asp:Repeater ID="article_rep" runat="server"

               onitemcommand="article_rep_ItemCommand">
               <itemtemplate>
                   <ul class="list1">
                       <li><a href="#"><%# Eval("Fl_Name")%></a></li>
                   </ul>
               </itemtemplate>
           </asp:Repeater>





代码背后是:



code behind is:

string connection_string = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\HILProject\project4\App_Data\adminlog.mdb";
        using (OleDbConnection cn = new OleDbConnection(connection_string))
        {

            cn.Open();
            String str = "select Fl_Name from Notification ";
            using (OleDbCommand command = new OleDbCommand(str, cn))
            {

                OleDbDataReader reader;
                reader = command.ExecuteReader();
                article_rep.DataSource = reader;
                article_rep.DataBind();
                cn.Close();
            }
        }

推荐答案

试试这些



Try these

<asp:hyperlink id="lnkDetails" runat="server" navigateurl="<%# GetUrl(Eval("Fl_Name"))%>" xmlns:asp="#unknown">
            <%#Eval("Fl_Name") %></asp:hyperlink>





代码背后代码





Code Behind code

public string GetUrl(object Fl_Name)
    {
        //logic for filepath
        
    }


试试这个.. :)







try this.. :)



<asp:repeater id="article_rep" runat="server" xmlns:asp="#unknown">
      onitemcommand="article_rep_ItemCommand">
      <itemtemplate>
          <ul class="list1">
              <li><a href="<%#Eval("Fl_Path") %>"> '<%#Eval("Fl_Name")%>'</a></li>
          </ul>
      </itemtemplate>
  </asp:repeater>







string connection_string = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\HILProject\project4\App_Data\adminlog.mdb";
        using (OleDbConnection cn = new OleDbConnection(connection_string))
        {
 
            cn.Open();
            String str = "select Fl_Name,Fl_Path from Notification ";
            using (OleDbCommand command = new OleDbCommand(str, cn))
            {
 
                OleDbDataReader reader;
                reader = command.ExecuteReader();
                article_rep.DataSource = reader;
                article_rep.DataBind();
                cn.Close();
            }
        }


这篇关于我想使用超链接从表中检索数据到打开文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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