Feeds:
Posts
Comments

Dear visitor,

Thanks to visit my Blog.

To see my latest blog posts please go to that link http://ashrafur.wordpress.com

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

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

guideline for programmer

http://www.pragmaticprogrammer.com/ppbook/extracts/rule_list.html

IsDate in ASP.NET

public static bool IsDate(Object obj)
{
        string strDate = obj.ToString();
        try
        {
            DateTime dt = DateTime.Parse(strDate);
            if((dt.Month!=System.DateTime.Now.Month) || (dt.Day<1&&dt.Day>31) || dt.Year!=System.DateTime.Now.Year)
                return false;
            else
                return true;
       }
       catch
       {
            return false;
       }
}