|
How do I have a gridview load with a specific row on the displayed page without filtering out all the other rows. ie if I'm showing 10 rows/page, and the row I want to show is the 37th I want it to load on page 4 instead of 1.
Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots.
-- Robert Royall
|
|
|
|
|
Why can't you set the 'PageIndex' property?
|
|
|
|
|
That would probably work, but how do I convert the PK into a row number if it's not guaranteed to be sequential?
Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots.
-- Robert Royall
|
|
|
|
|
int pageToShow=Row_Number%Rows_Per_Page==0?Row_Number/Rows_Per_Page:Row_Number/Rows_Per_Page+1
Can you use the above idea?
PageIndex=pageToShow;
EVEN THE WORD IMPOSSIBLE SAYS I M POSSIBLE.
|
|
|
|
|
My problem is converting the PK for the row into a row number. IF my query returns rows with PKs of: 1,2,4,5,8,12,44..., and I the row I want has a PK of 12, how do I use the PK to get the row number of 5?
Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots.
-- Robert Royall
|
|
|
|
|
There should be some relation between these PKs and the page numbers.
What is that relation?
dan neely wrote: I want has a PK of 12, how do I use the PK to get the row number of 5?
Why cant you use that 5* as the row number?
modified on Monday, July 21, 2008 11:06 AM
|
|
|
|
|
They represent every non deleted row in the table being queried. Before any deletion the PK and row numbers would be the same, after some rows are deleted that would no longer be the case. With arbitrary deletes there's no formula that can be used to convert between them. I'm asking if ASP/ADO.net provides any build in function to get the row, or if I have to manually iterate over the datasource until I find it.
Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots.
-- Robert Royall
|
|
|
|
|
dan neely wrote: I'm asking if ASP/ADO.net provides any build in function to get the row
I've no clue
|
|
|
|
|
The PK is coming from a source that displays a filtered subset of the data in a different order, so row numbers will not be the same.
Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots.
-- Robert Royall
|
|
|
|
|
Do you use DataKeyMember and DataKeyValue of the GridView? If you do so, you can easily see bij setting the SelectedIndex if the SelectedValue meets the required. If not found on page, go to next page of gridview.
You can also create a DataView which has a filter option. If you use that, bind the dataview as datasource to the gridview.
If you want 1 row to show, why you don't use the details view. That's made for 1 row of data.
|
|
|
|
|
Well if u r using a datatable for binding to a gridview, then you may try this...
1. Loop through the datatable using a for loop..
for(i=0;i<=tbl.Rows.Count-1;i++)
{
if(tbl.Rows[i].Item[0]=="Your PK")
break;
}
2> Use the value of i to get the position of your item in the table.
3>Now to get the page No...
for ex if the page size is 10 and i=37
then
newpage=ceil(37/10)=4
ie jump to 4th page.
and to find the item in the 4 th page use 37 mod 10, which returns the index of the item.
Hope it helps....
When you fail to plan, you are planning to fail.
|
|
|
|
|
I plan on allowing users to dynamically add, remove, and configure, menu items in a web site. Is there a nice way of providing the user with a list of eligible pages for links, or do I simply have to rely on detecting all pages in the main folder, or implement some kind of page manager?
|
|
|
|
|
It sounds to me like you are building a CMS. This is a big task. There may be open source ones available to you out there.
ASP.NET role manager may be of use if you want to build it yourself.
You can then allow certains users access to certain pages.
|
|
|
|
|
A very, very basic CMS function for a single site. They will have default menu items, and some optional informational pages that they would like to link to in the menu.
|
|
|
|
|
hi every one
actually i am submitting url of the image in database .at page 2 and now i want to show the image at page 3 .
for that i have to retrive the url from database and i am using
Image1.ImageUrl
but i am not able to retrive the correct image .
plz advice me what i should do .to retrive the image from database .
thanks gaurav
|
|
|
|
|
Do you store image path in Database? or in byte format?
If you store image path just set that path in src.
please don't forget to vote on the post that helped you.
|
|
|
|
|
thanks for the response
i am storing path in database and using this code for retrive the image .
OleDbConnection con1 = new OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=c:/image.mdb;");
OleDbCommand cmd1 = new OleDbCommand("select * from picture2");
cmd1.Connection = con1;
con1.Open();
OleDbDataReader dr1 = cmd1.ExecuteReader();
if (dr1.HasRows)
{
dr1.Read();
Image3.ImageUrl = dr1[0].ToString();
Image4.ImageUrl = dr1[1].ToString();
Image5.ImageUrl = dr1[2].ToString();
Image6.ImageUrl = dr1[3].ToString();
}
con1.Close();
now plz advise me what should i do.
|
|
|
|
|
|
hi i am using this code:
OleDbConnection con1 = new OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=c:/image.mdb;");
// OleDbConnection con1 = new OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=c:/image.mdb;");
OleDbCommand cmd1 = new OleDbCommand("select * from picture2");
cmd1.Connection = con1;
con1.Open();
OleDbDataReader dr1 = cmd1.ExecuteReader();
if (dr1.HasRows)
{
dr1.Read();
Image3.ImageUrl = dr1[0].ToString();
Image4.ImageUrl = dr1[1].ToString();
Image5.ImageUrl = dr1[2].ToString();
Image6.ImageUrl = dr1[3].ToString();
}
con1.Close();
plz suggest me.
|
|
|
|
|
hi every one
actually i am submitting url of the image in database .at page 2 and now i want to show the image at page 3 .
for that i have to retrive the url from database and i am using
Image1.ImageUrl
but i am not able to retrive the correct image .
plz advice me what i should do .to retrive the image from database .
thanks gaurav
|
|
|
|
|
gaurav mangal wrote: for that i have to retrive the url from database and i am using
So, your are saving image url in database.
Check My Article at Codeproject[^]
cheers,
Abhijit
|
|
|
|
|
yes
and using this code for retrive it
thanks for the response
i am storing path in database and using this code for retrive the image .
OleDbConnection con1 = new OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=c:/image.mdb;");
OleDbCommand cmd1 = new OleDbCommand("select * from picture2");
cmd1.Connection = con1;
con1.Open();
OleDbDataReader dr1 = cmd1.ExecuteReader();
if (dr1.HasRows)
{
dr1.Read();
Image3.ImageUrl = dr1[0].ToString();
Image4.ImageUrl = dr1[1].ToString();
Image5.ImageUrl = dr1[2].ToString();
Image6.ImageUrl = dr1[3].ToString();
}
con1.Close();
now plz advise me what should i do.
|
|
|
|
|
Where did you written this code ?
cheers,
Abhijit
|
|
|
|
|
hi
page 3 at which i want to show the images .
at page_load event.
|
|
|
|
|
Hi,
I'm creating a project in ASP.NET 2.0 using the controls GridView, FormView, and SqlDataSource. Everything is working as expected, but if the grid is empty FormView is not displayed. I've used separate SqlDataSource for GridView and formView. FormView is populated based on the row clicked in the Grid.
Initially grid would be empty, and New, Edit, Delete options of the FormView is not displayed coz formview itself is not displayed, coz grid has no data to display initially.
Is it possible to display the formview even if Grid is empty?
Regards,
Blumen
|
|
|
|