hi shashikant thanks for your reply below are code:
<div id="filmM21">
<asp:DropDownList ID="Ddljanr" runat="server" CssClass="ddljanrF"></asp:DropDownList>
<asp:DropDownList ID="Ddldaste" runat="server" CssClass="ddldasteF"></asp:DropDownList>
</div>
<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="false" Font-Size="14px"
DataKeyNames="Preference" OnRowDataBound="OnRowDataBound" PageSize="5" GridLines="Both"
PagerStyle-HorizontalAlign="Center" PagerStyle-VerticalAlign="Middle" ShowHeader="False"
Font-Names="behtop_Yekan" BackColor="#Fcfcfc" CssClass="gridGalary">
<Columns>
<asp:BoundField DataField="Id" ItemStyle-CssClass="databind" ItemStyle-Width="0px" />
<asp:TemplateField ItemStyle-Width="24px" ItemStyle-VerticalAlign="Middle">
<ItemTemplate>
<asp:Label ID="lblCustomerID1" runat="server" Text='<%# Eval("ID")%>' CommandArgument="lblCustomerID1"
Visible="false"></asp:Label>
<div id="divimgup">
<asp:ImageButton ID="lnkUp" runat="server" CssClass="imgupP" ImageUrl="~/Image/admin/imgup.png"
CommandArgument="up" OnClick="ChangePreference" CausesValidation="false" />
<asp:ImageButton ID="lnkDown" runat="server" CssClass="imgup1P" ImageUrl="~/Image/admin/imgup.png"
CommandArgument="down" OnClick="ChangePreference" CausesValidation="false" />
</div>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-Width="420px">
<ItemTemplate>
<div id="nameDocDivF">
<div id="nameGalaryF">
<asp:Label ID="lblNamep" runat="server" Text='<%# Eval("Name")%>' CssClass="lblnamePF"></asp:Label>
</div>
<div id="mainnameF">
<asp:Label ID="Label16" runat="server" Text="Finished" CssClass="finishedF" Visible='<%#(String.IsNullOrEmpty(Eval("finished").ToString()) ? false : true)%>'></asp:Label>
</div>
</div>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-Width="350px">
<ItemTemplate>
<div id="dastebandiFF">
<div id="dastebandiF">
<div id="dastebandi1F">
<asp:Label ID="lblclassp1" runat="server" Text='<%# Eval("Daste")%>' CssClass="lblclass1F"></asp:Label>
<asp:Label ID="lblclassp2" runat="server" Text='<%# Eval("Genre")%>' CssClass="lblclass2"></asp:Label>
</div>
</div>
</div>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<triggers>
<asp:AsyncPostBackTrigger ControlID = "GridView2" />
</triggers>
and
private void GetFilmInfo(int pageIndex)
{
using (SqlConnection conn = General.GetConnection())
{
using (SqlCommand cmd = General.GetCommand("Film_Information", conn))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@PageIndex", pageIndex);
cmd.Parameters.AddWithValue("@PageSize", PageSize);
if (Ddljanr.SelectedItem.Text != "انتخاب ژانر")
{
cmd.Parameters.AddWithValue("@Genre", Ddljanr.SelectedItem.Text);
}
if (Ddldaste.SelectedItem.Text != "دسته بندی")
{
cmd.Parameters.AddWithValue("@Daste", Ddldaste.SelectedItem.Text);
}
cmd.Parameters.Add("@RecordCount", SqlDbType.Int, 4);
cmd.Parameters["@RecordCount"].Direction = ParameterDirection.Output;
conn.Open();
SqlDataReader idr = cmd.ExecuteReader();
if (idr.HasRows)
{
GridView2.DataSource = idr;
GridView2.DataBind();
ImageButton lnkUp = (GridView2.Rows[0].FindControl("lnkUp") as ImageButton);
ImageButton lnkDown = (GridView2.Rows[GridView2.Rows.Count - 1].FindControl("lnkDown") as ImageButton);
lnkUp.Enabled = false;
lnkDown.Enabled = false;
}
else
{
GridView2.DataSource = idr;
GridView2.DataBind();
}
idr.Close();
this.PopulatePagerP(Convert.ToInt32(cmd.Parameters["@RecordCount"].Value), pageIndex);
}
}
}
SP:
ALTER PROCEDURE [dbo].[Film_Information]
@PageIndex INT = 1
,@PageSize INT = 5
,@RecordCount INT OUTPUT
,@Genre nvarchar(100)=null
,@Daste nvarchar(100)=null
AS
BEGIN
SET NOCOUNT ON;
SELECT ROW_NUMBER() OVER
(
ORDER BY [Preference]
)AS RowNumber
,id
,Name
,ISNULL([image],'2product.jpg') as image
,Code
,[date]
,Preference
,Status
,Daste
,Genre
,section
,Finished
INTO #Results
FROM SerialFilm
WHERE (Name IS NOT NULL)and(Genre=@Genre or @Genre is null)and(Daste=@Daste or @Daste is null)and(Finished=@Genre or @Genre is null)
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
protected void ChangePreference(object sender, ImageClickEventArgs e)
{
string commandArgument = (sender as ImageButton).CommandArgument;
int rowIndex = ((sender as ImageButton).NamingContainer as GridViewRow).RowIndex;
int locationId = Convert.ToInt32(GridView2.Rows[rowIndex].Cells[0].Text);
int preference = Convert.ToInt32(GridView2.DataKeys[rowIndex].Value);
preference = commandArgument == "up" ? preference - 1 : preference + 1;
this.UpdatePreference(locationId, preference);
rowIndex = commandArgument == "up" ? rowIndex - 1 : rowIndex + 1;
locationId = Convert.ToInt32(GridView2.Rows[rowIndex].Cells[0].Text);
preference = Convert.ToInt32(GridView2.DataKeys[rowIndex].Value);
preference = commandArgument == "up" ? preference + 1 : preference - 1;
this.UpdatePreference(locationId, preference);
this.GetFilmInfo(1);
}
ok
in this gridview shows films and serials information that bind from database and orderd by preference column I set for every film preference that by clicking in button in gridview:
<div id="divimgup">
<asp:ImageButton ID="lnkUp" runat="server" CssClass="imgupP" ImageUrl="~/Image/admin/imgup.png"
CommandArgument="up" OnClick="ChangePreference" CausesValidation="false" />
<asp:ImageButton ID="lnkDown" runat="server" CssClass="imgup1P" ImageUrl="~/Image/admin/imgup.png"
CommandArgument="down" OnClick="ChangePreference" CausesValidation="false" />
</div>
I can change row of table in database and define which film I want show upper than other films ...
and in gridview is Edit(linkbutton) that when I click on it, it will goes to Editfilm.aspx page that in this page I can edit film information...
protected void LinkButton11_Click(object sender, EventArgs e)
{
GridViewRow row = (sender as LinkButton).NamingContainer as GridViewRow;
int id = Convert.ToInt32(GridView2.DataKeys[row.RowIndex].Value);
using (SqlConnection conn = General.GetConnection())
{
using (SqlCommand cmd = General.GetCommand("Filmserial_Info", conn))
{
cmd.Parameters.AddWithValue("@id", id);
conn.Open();
object daste = cmd.ExecuteScalar();
conn.Close();
if (daste.ToString()=="film")
{
Response.Redirect("EditFilm.aspx? &id=" + id);
}
else
{
Response.Redirect("CreateSerial.aspx?&Id=" + id);
}
now problem is that when I click on Edit I want depend on Id columns it go to Editfilm.aspx page but it put preference column data for it I mean here:
cmd.Parameters.AddWithValue("@id", id);
I hope explain clearly...