i am working on bootstrap.i am displaying the news using datalist.Listview has one property called "PagePropertiesChanging". While datalist doesnt have any.How to implement paging in datalist?
I have the following code:
<div class="container">
<asp:DataList ID="Datasaved" runat="server" Width="100%">
<ItemTemplate>
<div class="row-fluid">
<div class="row">
<div class="col-xs-12 col-sm-3 col-md-3">
<a href="#">
<asp:Image runat="server" ID="ImgNews" class="img-responsive" style="" ImageUrl='<%# "~/images/newspictures/" + Eval("image")%>'/>
</a>
</div>
<div class="col-xs-12 col-sm-9 col-md-9">
<h4><a href="#"><asp:Label ID="newsheader" runat="server" Text='<%# Eval("newstitle") %>'></asp:Label></a></h4>
<p runat="server" style="text-align:justify;font-family: 'Poppins';font-size:16px;" id="newscontent" class=""><%# Eval("newsbrief") %> </p>
</div>
</div>
<hr/>
</div>
</ItemTemplate>
</asp:DataList>
<%-- <div class="center" style="text-align:center;">
<div class="pagination">
<asp:DataPager ID="DataPager1" PageSize="10" runat="server" QueryStringField="m_id" >
<Fields>
<asp:NextPreviousPagerField ShowLastPageButton="False" ShowNextPageButton="False" ButtonType="Button" ButtonCssClass="btn" RenderNonBreakingSpacesBetweenControls="false" />
<asp:NumericPagerField ButtonType="Button" RenderNonBreakingSpacesBetweenControls="false" NumericButtonCssClass="btn" CurrentPageLabelCssClass="btn disabled" NextPreviousButtonCssClass="btn" />
<asp:NextPreviousPagerField ShowFirstPageButton="False" ShowPreviousPageButton="False" ButtonType="Button" ButtonCssClass="btn" RenderNonBreakingSpacesBetweenControls="false" />
</Fields>
</asp:DataPager>
</div>
</div>--%>
</div>
I tried to add code for pagination as seen above.. class=pagination.but i dont know what to write in code behind.(i commented the pagination class)
Code behind:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
KeywordSearch();
}
}
protected void KeywordSearch()
{
string constr = ConfigurationManager.ConnectionStrings["mysqldbeConnectionString"].ConnectionString;
using (MySqlConnection con = new MySqlConnection(constr))
{
using (MySqlCommand cmd = new MySqlCommand("SELECT * FROM news WHERE status=1 ORDER BY priority DESC,datepublished DESC,rating DESC LIMIT 10"))
{
cmd.Connection = con;
cmd.CommandType = CommandType.Text;
MySqlDataAdapter da = new MySqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
Datasaved.DataSource = dt;
Datasaved.DataBind();
}
}
}