Click here to Skip to main content
14,359,094 members
Rate this:
Please Sign up or sign in to vote.
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???
Rate this:
Please Sign up or sign in to vote.

Solution 1

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: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
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.
   
Rate this:
Please Sign up or sign in to vote.

Solution 2

You can use your listview item as a hyperlink

Try something like

<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
   
Rate this:
Please Sign up or sign in to vote.

Solution 3

<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>
   
v2

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




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100