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 ChoudharyPosted Mar 19, 2010, 8:36 AM
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.
Dipa AhujaPosted Mar 19, 2010, 9:28 AM
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..
Dipa AhujaPosted Mar 18, 2010, 1:04 PM
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..
Amit ChoudharyPosted Mar 18, 2010, 3:49 AM
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:
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.