|
.net
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How to add Label control to DataList?How do i Add a Lable control to DataList to show the Count Files which belong the current Category. i have a DataList which displays categoryName,Description and File counter (coutn the images belong to category), i able to display first 2 values from database, but how to dispalyg the image counted data in DataList ? Here is my code which doesnt working:(i am using code behind to pull the data from DB) <ItemTemplate> <table cellpadding=10 style="font: 11px verdana" border="0" class="border" width="100%" height="160"> <tr><td valign="top"><div class="thumb"><a href='<%# DataBinder.Eval(Container.DataItem, "CatID", "ShowThumbnails.aspx?qsCatID={0}") %>' ><img align="top" src="Images/splash.gif"></a></div></td></tr> <tr><td>Category: <b><%#DataBinder.Eval(Container.DataItem, "CategoryName")%></b><br> Description: <%#DataBinder.Eval(Container.DataItem, "Description")%><br> Files Count:<b><asp:Label ID="lblCountFiles" runat="server"></asp:Label> </b></td></tr></table> </ItemTemplate> in code behind file it gives me an error that "lblCountFiles" not declared. It seems you are trying to refer to the Label directly in your code behind.
You will have to use FindControl() method of DataListItem in your IteamDataBound event to get the label object. And using that object you can set the value. Hope that helps. If not please post the code behind code as well so that it can be checked for possible errors. Regards, HP Show quoteHide quote "Jameel" wrote: > Hi Coders, > > How do i Add a Lable control to DataList to show the Count Files which > belong the current Category. > > i have a DataList which displays categoryName,Description and File counter > (coutn the images belong to category), i able to display first 2 values from > database, but how to dispalyg the image counted data in DataList ? > Here is my code which doesnt working:(i am using code behind to pull the > data from DB) > <ItemTemplate> > > <table cellpadding=10 style="font: 11px verdana" border="0" class="border" > width="100%" height="160"> > > <tr><td valign="top"><div class="thumb"><a href='<%# > DataBinder.Eval(Container.DataItem, "CatID", > "ShowThumbnails.aspx?qsCatID={0}") %>' ><img align="top" > src="Images/splash.gif"></a></div></td></tr> > > > <tr><td>Category: <b><%#DataBinder.Eval(Container.DataItem, > "CategoryName")%></b><br> > > Description: <%#DataBinder.Eval(Container.DataItem, "Description")%><br> > > Files Count:<b><asp:Label ID="lblCountFiles" runat="server"></asp:Label> > </b></td></tr></table> > > </ItemTemplate> > > in code behind file it gives me an error that "lblCountFiles" not declared. > > >
Other interesting topics
HTTPModule/HTTPHandler to process request
must use updateable query request specific holding location.... hitting enter button while in textbox calls correct button's click event GredView {0:d} formatting doesn't work How do I show a sectioned list? Asp DropDownList Horizontal CSS drop-down menu? Dynamically Loading the User Control and Passing Parameters to it. Fail to save xmldocument |
|||||||||||||||||||||||