Click here to Skip to main content
16,016,227 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:
XML
<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:
C#
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();
            }
        }
Posted

try this.. :)



ASP.NET
<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>


C#
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();
            }
        }
 
Share this answer
 
Comments
Bhushan Patki 4-Jun-14 5:21am    
i think Fl_Path is not store in notification table
Nirav Prabtani 4-Jun-14 7:22am    
Why have you think that??
Ashwini Thakare 4-Jun-14 7:17am    
thank you.....
Nirav Prabtani 4-Jun-14 7:22am    
welcome.. :)
Try these

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


Code Behind code

C#
public string GetUrl(object Fl_Name)
    {
        //logic for filepath
        
    }
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900