replace all <> with @ and !
C# ASP.NET DataList Control Code
@asp:DataList ID="dataList" runat="server" RepeatDirection="Horizontal" BackColor="White" BorderColor="White" BorderStyle="Ridge" BorderWidth="2px" CellPadding="3" CellSpacing="1"!
@ItemTemplate!
@table!
@tr!
@td style="width:97px;"!@%# DataBinder.Eval(Container.DataItem, "Column1") %!@/td!
@/tr!
@/table!
@/ItemTemplate!
@AlternatingItemTemplate!
@table!
@tr!
@td style="width:97px;"!@%# DataBinder.Eval(Container.DataItem, "Column1") %!@/td!
@/tr!
@/table!
@/AlternatingItemTemplate!
@FooterStyle BackColor="#C6C3C6" ForeColor="Black" /!
@SelectedItemStyle BackColor="#9471DE" Font-Bold="True" ForeColor="White" /!
@ItemStyle BackColor="#DEDFDE" ForeColor="Black" /!
@HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#E7E7FF" /!
@/asp:DataList!
@asp:Button ID="imgBtnRewind" runat="server" OnClick="imgBtnRewind_Click" Text="<<" /! @asp:Button ID="imgbtnff" runat="server" OnClick="imgbtnff_Click"" Text=">>" /!
C# Code
PagedDataSource pgdDatasource;
DataTable dtBirthdays;
private int CurrentPage
{
get
{
object o = this.ViewState["_CurrentPage"];
if (o == null)
return 0;
else
return (int)o;
}
set
{
ViewState["_CurrentPage"] = value;
}
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
DataTest(true);
else
DataTest(false);
}
public void DataTest(bool a)
{
if (a)
CurrentPage = 0;
imgBtnRewind.Enabled = true;
imgbtnff.Enabled = true;
dtBirthdays = objDBHelper.GetReaderTable("SELECT edEventID FROM EventDetails", 1);
pgdDatasource = new PagedDataSource();
pgdDatasource.DataSource = dtBirthdays.DefaultView;
pgdDatasource.AllowPaging = true;
pgdDatasource.PageSize = 3;
pgdDatasource.CurrentPageIndex = CurrentPage;
Button1.Visible =!pgdDatasource.IsFirstPage;
Button2.Visible =!pgdDatasource.IsLastPage;
datalist.DataSource = pgdDatasource;
datalist.DataBind();
Response.Write(dtBirthdays.Rows.Count);
}
protected void imgBtnRewind_Click(object sender, ImageClickEventArgs e)
{
CurrentPage -= 1;
RepeaterTest(false);
}
protected void imgbtnff_Click(object sender, ImageClickEventArgs e)
{
CurrentPage += 1;
RepeaterTest(false);
}
}
No comments:
Post a Comment