i have one page..
photos.aspx: in that i have datalist wich display all photos..
when user clicks on any of the photo it wil be opened in display.aspx..
now here i have used form view and bind with sqldatasource
now i want that when user click on photos.aspx it display that photo in display.aspx
so i use querystring parameter in sqldatasource's where condition
bt i want it to display all photos in display.aspx by using paging...
with querystring parameter it just show the one photo..
its same like albums in social networking websites so how to do?


Amit ChoudharyRank #145 · 15.8K reputationPosted Mar 19, 2010, 4:36 AM EDT
its a trick.. see when you fetch the data from database to datatable or dataset then your photoid have the same index in datatable as in gridview... when you bind them
so find the index in datatable.. the same index will be in gridview. use the index to set the GridView.PageIndex and bind the grid.. you grid will open the same photo that you pass in the URL. and by paging you can also navigate to other photos too...
hope you got it.
Amit ChoudharyRank #145 · 15.8K reputationPosted Mar 17, 2010, 11:49 PM EDT
you can take simple gridview with set the attribute to page size="1" and allow paging="true"..... Implement its pageInex_changing and pageIndex_chagned event like this:
protected void grvCases_PageIndexChanging(object sender, GridViewPageEventArgs e) { try { GridView1.PageIndex = e.NewPageIndex;you can pass the imageid/PhotoId in QueryString and based on that get the index of the photo and then on page load set the grid index with that... here is BindGrid () method that bind the grid and set the index according to the image id
private void BindGrid()
{
GridView1.DataSource = CollectionPhoto.getPhotos(CID).DefaultView;
if (!Page.IsPostBack)
{
GridView1.PageIndex = getIndex(Imgid);
}
GridView1.DataBind();
lblCount.Text = CollectionPhoto.getPhotos(CID).RowCount.ToString();
}
Please mark as answer if it helps.
Dipa AhujaRank #1,168 · 1.5K reputationPosted Mar 18, 2010, 9:04 AM EDT
c i have already used that query string parameter n binded the gridview with sqldata source.. bt i m not getting how to set its index based on photoId...
bcoz its not neccessary that photoid is same as index of gridview being confused..
Dipa AhujaRank #1,168 · 1.5K reputationPosted Mar 19, 2010, 5:28 AM EDT
protected void Page_Load(object sender, EventArgs e)
{
string PID = Request.QueryString["ImgId"];
da = new SqlDataAdapter("select * from photos", connstring);
ds=new DataSet();
da.Fill(ds);
for (int j = 0; j < ds.Tables[0].Rows.Count; j++)
{
search = ds.Tables[0].Rows[j]["ImgId"].ToString();
if (search == PID)
{
FormView1.PageIndex = j;
}
FormView1.DataBind();
}
}
thanx i mark your answer..