Click here to Skip to main content
15,891,951 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to create a "listView" using DataSource in Report, in which the list should contain item which can make a link.
Posted
Comments
JoCodes 14-Oct-13 2:32am    
item which can make a link???? Also whats the report you are using?
hira_1 14-Oct-13 2:38am    
i meant by link when any item is pressed that displays the result on the repeater and Report is just to sdiplay the combine result on a repeater ..
hira_1 14-Oct-13 2:40am    
Let e precise my question .. i want to create a "list" containing item and those item makes a link
JoCodes 14-Oct-13 3:07am    
So what I understand is you want to click on an item( hyperlink ) on the Listview and it should take you to the details???

C#
<asp:listview runat="server" id="listViewEmp" itemplaceholderid="itemPlaceholder" xmlns:asp="#unknown">
  <layouttemplate>
    <table>
      <tr runat="server" id="itemPlaceholder"></tr>
    </table>
  </layouttemplate>
  <itemtemplate>
    <tr>
      <td>
          <asp:hyperlink id="lnkView" runat="server" text="<%#Eval("Name") %>" navigateurl="<%#"ViewDetail.aspx?ItemID="+ Eval("ItemID") %>" />
      </td>
    </tr>
  </itemtemplate>
</asp:listview>
 
Share this answer
 
v2
You can use your listview item as a hyperlink

Try something like

XML
<asp:ListView runat="server" ID="lvItems"

    DataSourceID="SqlDataSourceBind" DataKeyNames="ID">

  <ItemTemplate>
      <asp:HyperLink ID="linkID" runat="server"
           Target="_blank" Text='<% #Eval("Name")%>'
           NavigateUrl='<%#"ShowUrl.aspx?ID=" +
              Eval("ID") %>' />
  </ItemTemplate>
</asp:ListView>


Hope this helps
 
Share this answer
 
Hi,
here is a sample Listview and how to bind it from databse with links in the Listview to navigate to detail page with querystring
ASP.NET
<asp:listview runat="server" id="listViewEmp" itemplaceholderid="itemPlaceholder" xmlns:asp="#unknown">
  <layouttemplate>
    <table>
      <tr runat="server" id="itemPlaceholder"></tr>
    </table>
  </layouttemplate>
  <itemtemplate>
    <tr>
      <td>
          <asp:hyperlink id="lnkView" runat="server" text="<%#Eval("Name") %>" navigateurl="<%#"ViewDetail.aspx?EmpID="+ Eval("EmployeeID") %>" />
      </td>
    </tr>
  </itemtemplate>
</asp:listview>
and c# code to bind
C#
private void Page_Load(object sender, System.EventArgs e)
       {
           string connString = "Your connectionstring";
           string sql = @"Select * From Employees";
           SqlConnection conn = new SqlConnection(connString);
           SqlDataAdapter da = new SqlDataAdapter(sql, conn);
           da.Fill(dataSet1, "employee");
           DataTable dt = dataSet1.Tables["employee"];
           listViewEmp.DataSource = dt;
           listViewEmp.DataBind();
       }

In this example there is a Link to view the details of Employee that will redirect to Detail.aspx
Hope this will give you better idea to acieve your task.
 
Share this answer
 

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