Data List with paging and Select Image on a data list

006Ashish
Posted by 006Ashish under ASP.NET category on | Points: 40 | Views : 2316
In data list page is running fine but when I am selecting a image from data list it will show a differnet image...

If I am using int i=0, not current page, then select image is okat and in paging imare are not change

I am using page size=4 here

in case of page size 1 every thing is working fine

please do the solutyion

code is here...






using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using BO.BOProperty;
using BAL.BalProperty;
using BAL.util;


namespace iDeal.Home
{
public partial class HomePage : System.Web.UI.Page
{


PagedDataSource obj = new PagedDataSource();


string path;
static DataTable dtt = new DataTable();
protected void Page_Load(object sender, EventArgs e)
{
path = HttpContext.Current.Request.MapPath(HttpContext.Current.Request.ApplicationPath) + "ErrorLog\\";
if (!IsPostBack)
{
HotPropities();
}

upd_adroater.Update();
}



private void HotPropities()
{


BALPropertySearch bvsrch = new BALPropertySearch();
BOPropertySearch bos = new BOPropertySearch();
bos.is_main = Convert.ToBoolean(1);
bos.category_name = "Deal_type";
bos.subcatname_name = "Hot_Deals";
dtt = bvsrch.View_PropertyAll(bos);

try
{
if (dtt.Rows.Count > 0)
{

obj.DataSource = dtt.DefaultView;
obj.AllowPaging = true;
obj.PageSize = 4;
obj.CurrentPageIndex = 1;
ViewState["Pageindex"] = obj.CurrentPageIndex;
dlst_prpimages.DataSource = obj;
dlst_prpimages.DataBind();
tab1.Visible = true;

}
else
{
tab1.Visible = false;

}



Hashtable htt = new Hashtable();
int i = CurrentPage;
foreach (DataListItem dli in dlst_prpimages.Items)
{



ImageButton prod_img = (ImageButton)dli.FindControl("prodimage");
Label prpprice = (Label)dli.FindControl("lblshort");
Label prphead = (Label)dli.FindControl("lbltitle");
Label prpid = (Label)dli.FindControl("lblpropid");
// LinkButton lnkredirect = (LinkButton)dli.FindControl("lnkBTN");

string ismain = (Convert.ToBoolean(dtt.Rows[i]["is_main"].ToString())) ? "1" : "0";
prod_img.ImageUrl = "../ImageHandler.ashx?id=" + dtt.Rows[i]["prop_id"].ToString() + "&is_main=" + ismain; //+ "&idd=" + dtt.Rows[i]["id1"].ToString();
prphead.Text = dtt.Rows[i]["property_heading"].ToString();
prpprice.Text = dtt.Rows[i]["property_price"].ToString();
prpid.Text = dtt.Rows[i]["prop_id"].ToString();
// lnkredirect.Text = dtt.Rows[i]["prop_id"].ToString();
i++;

}

}
catch (Exception ex)
{

new common().errorLog(path, ex);

}

UP_SEARCHGRID.Update();

}
public int CurrentPage
{

get
{
if (this.ViewState["CurrentPage"] == null)
return 0;
else
return Convert.ToInt16(this.ViewState["CurrentPage"].ToString());
}

set
{
this.ViewState["CurrentPage"] = value;
}

}
protected void dlst_prpimages_ItemCommand(object source, DataListCommandEventArgs e)
{
string prp_id = null;
if (e.CommandName == "Select")
{

prp_id = dlst_prpimages.DataKeys[e.Item.ItemIndex].ToString();


Response.Redirect("ImageDescription.aspx?id=" + prp_id);
}


}

protected void btnNext_Click(object sender, EventArgs e)
{
CurrentPage += 4;
//int pagesize = (int)ViewState["Pageindex"];
//int pagesizeincre = pagesize + 1;
//ViewState["pagesizeincre"] = pagesizeincre;
HotPropities();
}
protected void btnPrev_Click(object sender, EventArgs e)
{
CurrentPage -= 4;
HotPropities();
}
protected void btnBack_Click(object sender, EventArgs e)
{
Response.Redirect("Home.aspx");
}

protected void lnkBTN_Click(object sender, EventArgs e)
{
//int prop = (int)ViewState["prp"];
//Response.Redirect("ImageDescription.aspx?id=" + prop);
}

protected void lnkBTN_Command(Object sender, CommandEventArgs e)
{
int prodidh = 0;
if (e.CommandArgument == "Select")
{
int prodid = Convert.ToInt32(e.CommandArgument.ToString());
foreach (DataRow rw in dtt.Rows)
{
if (Convert.ToInt32(rw["prop_id"].ToString()) == prodid)
{
//Response.Redirect("ImageDescription.aspx?id=" + prodid);
prodidh = int.Parse(rw["prop_id"].ToString());
}
}
ViewState["prp"] = prodidh;

}




}

}
}


Please give me the solution

Comments or Responses

Login to post response