Feeds:
Posts
Comments

Archive for September, 2007

paging in asp:DataList

asp:DataList has to paging option by default but it is easy to make pagination in datalist using “PagedDataSource Class”

HTML code is:

<table width=”100%”>
<tr><td>
<asp:DataList ID=”dlPhotos” Runat=”server” Width=”100%” ItemStyle-HorizontalAlign=”Left” RepeatLayout=”Table” RepeatDirection=”Horizontal” RepeatColumns=”4″ OnItemDataBound=”dlPhotos_ItemDataBound”>
<ItemTemplate>
<asp:Image id=”imgThumbnail” runat=”server” borderSize=”5″ />
</ItemTemplate>
</asp:DataList>
</td></tr>
<tr><td>
<table width=”100%”>
<tr>
<td align=”left”><asp:LinkButton runat=”server” ID=”lnkPrev” OnClick=”lnkPrev_Click” >Prev</asp:LinkButton></td>
<td align=”right”><asp:LinkButton runat=”server” ID=”lnkNext” OnClick=”lnkNext_Click” >Next</asp:LinkButton></td>
</tr>
</table>
</td></tr>
</table>

Code for the pagination is:

public void ShowPhotos()
{
try
{
PagedDataSource objPage = new PagedDataSource();
DataSet dsImgs = ….\\datasource
objPage.AllowPaging=true;
objPage.DataSource = dsImgs.Tables[0].DefaultView;
objPage.PageSize = 12;
objPage.CurrentPageIndex = CurrentPage; //CurrentPage is a static variable
dlPhotos.DataSource = objPage;
dlPhotos.DataBind();
}
catch (Exception ex)
{
lblError.Text = ex.Message ;
}
}
protected void lnkPrev_Click(object sender, EventArgs e)
{
CurrentPage -=1;
ShowPhotos();
}
protected void lnkNext_Click(object sender, EventArgs e)
{
CurrentPage+=1;
ShowPhotos();
}

thats just a sample, please customize it for your works

Advertisements

Read Full Post »

Components of Ajax

Ajax components are:

1. Javascript:  Scripting language that commonly hosted in a browser to add interactively to HTML pages

2. DOM (Document Object Model): DOM is leveraged to efficiently redraw portions og hte pages.

3. CSS (Cascading Style Sheets) : modify the exterior of the user interface interactively

4. XMLHttpRequest: opposed to performing a full-page refresh or postback

Read Full Post »