Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. repeater control in ASP.Net with C#

repeater control in ASP.Net with C#

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netquestion
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mahichandu
    wrote on last edited by
    #1

    Hey am using repeater control to populate the data using datatable.. in my table the row cells some has values some has 0(zero) value.... i have to make the value of cell as hyperlink/button ..how can i do tht..my table looks like as i given blow.. Could any one suggest me...:confused:

    Jurdiction 2007 2008 2009
    NC 0 6 3
    VA 4 0 5
    NY 0 7 0

    M N 2 Replies Last reply
    0
    • M mahichandu

      Hey am using repeater control to populate the data using datatable.. in my table the row cells some has values some has 0(zero) value.... i have to make the value of cell as hyperlink/button ..how can i do tht..my table looks like as i given blow.. Could any one suggest me...:confused:

      Jurdiction 2007 2008 2009
      NC 0 6 3
      VA 4 0 5
      NY 0 7 0

      M Offline
      M Offline
      Manas Bhardwaj
      wrote on last edited by
      #2

      mahichandu wrote:

      in my table the row cells some has values some has 0(zero) value.... i have to make the value of cell as hyperlink/button

      Well, to treat partiular data case by case, you can not use databind method. Instead, you should use a loop and add the items. Check the data and if it matches your condition(as you say 0 here), make the that a Hyperlink Column.:rose:

      Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.

      M 1 Reply Last reply
      0
      • M Manas Bhardwaj

        mahichandu wrote:

        in my table the row cells some has values some has 0(zero) value.... i have to make the value of cell as hyperlink/button

        Well, to treat partiular data case by case, you can not use databind method. Instead, you should use a loop and add the items. Check the data and if it matches your condition(as you say 0 here), make the that a Hyperlink Column.:rose:

        Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.

        M Offline
        M Offline
        mahichandu
        wrote on last edited by
        #3

        hmmmm..:( could ou just send me sample code which way i have to add..which event i have to add this looping statements..in Pageload only na... i don't have much knowledge on C# technolgies.. I am thinking i have to to take new datatable..adding the item & check the data..hear how to prceed.. Could u do this help :((

        N 1 Reply Last reply
        0
        • M mahichandu

          Hey am using repeater control to populate the data using datatable.. in my table the row cells some has values some has 0(zero) value.... i have to make the value of cell as hyperlink/button ..how can i do tht..my table looks like as i given blow.. Could any one suggest me...:confused:

          Jurdiction 2007 2008 2009
          NC 0 6 3
          VA 4 0 5
          NY 0 7 0

          N Offline
          N Offline
          Niladri_Biswas
          wrote on last edited by
          #4

          There are may ways of doing the same. I am presenting one way of doing it I am taking a datatable as my datasource(and ofcourse you have also taken that :) ) So here it goes Step 1: Create datatable

          DataTable dtSource = new DataTable();

              #region Data Table Creation
          
              dtSource.Columns.Add("Jurdiction");
              dtSource.Columns.Add("2007");
              dtSource.Columns.Add("2008");
              dtSource.Columns.Add("2009");        
          
              #endregion
          
              #region Add Rows
              dtSource.Rows.Add("NC", "0", "6", "3");
              dtSource.Rows.Add("VA", "4", "0", "5");
              dtSource.Rows.Add("NY", "0", "7", "0");
              
              #endregion
          

          Step 2:Create a repeater control in your .aspx page

          <asp:Repeater ID="myRepeater" runat="server">
          </asp:Repeater>

          Step 3:Bind the datatable to the repeater control which is there in the .aspx page

          myRepeater.DataSource = dtSource;
          myRepeater.DataBind();

          Step 4:Create a user control say Headercontrol.ascx

          <%@ Control Language="C#" AutoEventWireup="true" CodeFile="HeaderControl.ascx.cs" Inherits="HeaderControl" %>
          <table width="40%">
          <tr>
          <td style="width:10%">
          <asp:Label ID="lblHeaderCol1" runat="server" Text="Jurdiction"></asp:Label>
          </td>
          <td style="width:10%">
          <asp:Label ID="lblHeaderCol2" runat="server" Text="2007"></asp:Label>
          </td>
          <td style="width:10%">
          <asp:Label ID="lblHeaderCol3" runat="server" Text="2008"></asp:Label>
          </td>
          <td style="width:10%">
          <asp:Label ID="lblHeaderCol4" runat="server" Text="2009"></asp:Label>
          </td>
          </tr>
          </table>

          Step 5:Create another user control say ContentControl.ascx

          <%@ Control Language="C#" AutoEventWireup="true" CodeFile="ContentControl.ascx.cs" Inherits="ContentControl" %>

          <table width="40%">
          <tr>
          <td style="width:10%">
          <asp:Label ID="lblContentColumn1" runat="server"></asp:Label>
          </td>
          <td style="width:10%">
          <asp:LinkButton ID="lnkContentColumn2" runat="server"></asp:LinkButton>
          </td>
          <td style="width:10%">
          <asp:LinkButton ID="lnkContentColumn3" runat="server"></asp:LinkButton>
          </td>
          <td style="width:10%">

          1 Reply Last reply
          0
          • M mahichandu

            hmmmm..:( could ou just send me sample code which way i have to add..which event i have to add this looping statements..in Pageload only na... i don't have much knowledge on C# technolgies.. I am thinking i have to to take new datatable..adding the item & check the data..hear how to prceed.. Could u do this help :((

            N Offline
            N Offline
            Niladri_Biswas
            wrote on last edited by
            #5

            Alternatively you can look into here http://www.netrostar.com/Tutorials-91-ASP.NET%20Tutorial.%20How%20to%20use%20Repeater[^]

            Niladri Biswas

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups