repeater control in ASP.Net with C#
-
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 -
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 0mahichandu 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.
-
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.
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 :((
-
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 0There 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%"> -
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 :((
Alternatively you can look into here http://www.netrostar.com/Tutorials-91-ASP.NET%20Tutorial.%20How%20to%20use%20Repeater[^]
Niladri Biswas