hi dharmendr
I bind DLserial from databse see below is code:
if (!IsPostBack)
{
this.GetCustomersPageWise(1);
}
private void GetCustomersPageWise(int pageIndex)
{
using (SqlConnection conn = General.GetConnection())
{
using (SqlCommand cmd = General.GetCommand("GetCustomersPageWiseSerial", conn))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@PageIndex", pageIndex);
cmd.Parameters.AddWithValue("@PageSize", PageSize);
cmd.Parameters.AddWithValue("@Genre", ddlGenre.SelectedItem.Text);
cmd.Parameters.Add("@RecordCount", SqlDbType.Int, 4);
cmd.Parameters["@RecordCount"].Direction = ParameterDirection.Output;
conn.Open();
SqlDataReader idr = cmd.ExecuteReader();
if (idr.HasRows)
{
DLSerial.DataSource = idr;
DLSerial.DataBind();
rptPager.Visible = !(rptPager2.Visible = false);
}
idr.Close();
this.PopulatePager(Convert.ToInt32(cmd.Parameters["@RecordCount"].Value), pageIndex);
}
}
}
and SP:
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[GetCustomersPageWiseSerial]
@PageIndex INT = 1
,@PageSize INT = 5
,@RecordCount INT OUTPUT
,@Genre nvarchar(100)
AS
BEGIN
SET NOCOUNT ON;
SELECT ROW_NUMBER() OVER
(
ORDER BY [Date] desc
)AS RowNumber
,[ID]
,ImageCover
,ImageDetail
,[Date]
,[ImageName]
,[Code]
,AparatLink
,SE1,SE2,SE3,SE4,SE5,SE6,SE7,SE8,SE9,SE10,SE11,SE12,SE13,SE14,SE15,SE16,SE17,SE18,SE19,SE20,SE21,SE22,SE23,SE24,SE25,SE26,SE27,SE28,SE29,SE30
,SE1p,SE2p,SE3p,SE4p,SE5p,SE6p,SE7p,SE8p,SE9p,SE10p,SE11p,SE12p,SE13p,SE14p,SE15p,SE16p,SE17p,SE18p,SE19p,SE20p,SE21p,SE22p,SE23p,SE24p,SE25p,SE26p,SE27p,SE28p,SE29p,SE30p
,SeasonAllP
INTO #Results
FROM [SerialFilm]
where (Genre=@Genre or @Genre=N'تمامی موارد')and Daste=N'سریال'
SELECT @RecordCount = COUNT(*)
FROM #Results
SELECT * FROM #Results
WHERE RowNumber BETWEEN(@PageIndex -1) * @PageSize + 1 AND(((@PageIndex -1) * @PageSize + 1) + @PageSize) - 1
DROP TABLE #Results
END
and html:
<asp:DataList ID="DLSerial" runat="server" RepeatDirection="Vertical" CssClass="Dlfilm">
<ItemTemplate>
<asp:Label ID="Label4" runat="server" CssClass="LblcodeF" Text='<%# Eval("Code") %>'></asp:Label>
<asp:Image ID="Image3" runat="server" ImageUrl='<%#Eval("ImageName","image/Film/Name/{0}")%>' CssClass="ImgNameF"></asp:Image>
<div id="ses22">
<asp:Label ID="Label7" runat="server" CssClass="se1">فصل 1:</asp:Label>
<asp:CheckBox ID="Chfilm" runat="server" CssClass="ch1"></asp:CheckBox>
</div>
<div id="ses22">
<asp:Label ID="Label9" runat="server" CssClass="se1">فصل 2:</asp:Label>
<asp:CheckBox ID="Chserial" runat="server" CssClass="ch1"></asp:CheckBox>
</div>
<div id="ses22">
<asp:Label ID="Label11" runat="server" CssClass="se1">فصل 3:</asp:Label>
<asp:CheckBox ID="ChAnimation" runat="server" CssClass="ch1"></asp:CheckBox>
</div>
</ItemTemplate>
</asp:DataList>
and datalist Items are morethan this I just put some of them in above code:
so I can't wrote:
DataTable dLMostanad = new DataTable();
dLMostanad.Columns.AddRange(new DataColumn[] {
new DataColumn("Id",typeof(int)),new DataColumn("Name",typeof(string)),new DataColumn("Quality",typeof(string)),
new DataColumn("PriceT", typeof(string)), new DataColumn("Price", typeof(string)), new DataColumn("Quanyity", typeof(string)),
new DataColumn("code",typeof(string)),new DataColumn("Type",typeof(string)),new DataColumn("SectionName",typeof(string)),
new DataColumn("buy",typeof(string)),new DataColumn("show",typeof(string)) });
dLMostanad.Rows.Add();
DLSerial.DataSource = dLMostanad;
DLSerial.DataBind();