Ramani Sandeep's Blog

DotNetting – Fast , Easy Way of Developing Applications

Archive for March, 2009

ASP.NET Page Lifecycle

Posted by Ramani Sandeep on March 16, 2009

Posted in .Net Framework, ASP.NET | Tagged: , | 1 Comment »

Repeater : Format Particular Cell in ItemDataBound using HtmlTableCell

Posted by Ramani Sandeep on March 7, 2009

In My one of the Project i need to display Data in repeater control with certain criteria.Criteria like i need to highlight particular cell when it is null so i want to change background of that cell so that it hightlight.so i feel this might be helpful to you also. so i m writing this post.It really very useful , u can also use this in yr application when need arise.

======================================================================
ASPX :
======================================================================

<asp:Repeater ID=”rpt” runat=”server” OnItemDataBound=”rpt_ItemDataBound” >
<ItemTemplate>
<tr>
<td id=”tdmon” runat=”server” align=”center”>
<asp:Label ID=”lblMon” runat=”server” Text=’<%# Eval(“monReason”) %>’></asp:Label>
<asp:LinkButton ID=”lnkMon” runat=”server”></asp:LinkButton>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>

======================================================================
CS :
======================================================================

protected void rpt_ItemDataBound(object sender, RepeaterItemEventArgs e)
{

if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
if (string.IsNullOrEmpty(((Label)e.Item.FindControl(“lblMon”)).Text))
{
((LinkButton)e.Item.FindControl(“lnkMon”)).Text = “Select”;

}
else
{

((HtmlTableCell)e.Item.FindControl(“tdmon”)).Attributes.Add(“class”, “Cell_Sceduleing_Highlight”);
}
}

}

Happy Programming !!!

Posted in ADO.NET, ASP.NET | Tagged: , , , | Leave a Comment »