Showing posts with label datalist. Show all posts
Showing posts with label datalist. Show all posts

Thursday, November 10, 2011

Empty Footer Template in Datalist

<FooterTemplate>
<asp:Label runat="server" ID="dlVideosFooter" Text="No Vidoes available at this moment for the selected category.Please try later or select another category"
Visible='<%#bool.Parse((dlBuzzVideos.Items.Count==0).ToString()) %>'></asp:Label>
</FooterTemplate>

Note:dlBuzzVideos is the datalist id.

Trim a DataBound Linkbutton inside a DataList

<ItemTemplate>

<asp:LinkButton ID="LinkButton1" runat="server" Text='<%
getShortString(Eval("Location1")) %>'></asp:LinkButton>
</ItemTemplate>
</asp:DataList>

protected string getShortString(object value)
{
string shrtString = value.ToString();
if (shrtString.Length > 4) // Change this value to set your character limit
{
shrtString = shrtString.Substring(0, 4) + "..."; // Change this value to set your character limit

}
return (shrtString);
}

source : http://forums.asp.net/t/1521615.aspx/1

Friday, July 1, 2011

Displaying Pageresults of a Gridview/Datalist

lblPageinfo.Text="Showing results: " + (_PageDataSource.CurrentPageIndex * _PageDataSource.PageSize + 1) + "-" + (_PageDataSource.CurrentPageIndex * _PageDataSource.PageSize + dlSearchJobs.Items.Count) + " of " + _PageDataSource.DataSourceCount ;

  • where _PageDataSource is the object of PagedDataSource class
  • PagedDataSource _PageDataSource = new PagedDataSource();
  • dlSearchJobs is the Datalist used to display results from DB

output : Showing results: 1-10 of 43

if using GRIDVIEW

lblPageinfo.Text="Showing results: " +(gvInbox.PageIndex) * gvInbox.PageSize + 1) + "-" + (gvInbox.PageIndex* gvInbox.PageSize+ gvInbox.Rows.Count) + " of " + objData.Length ;

  • where gvInbox is the Gridview
  • objData is the Datasource for Gridview