Link to home
Start Free TrialLog in
Avatar of hconant
hconantFlag for United States of America

asked on

Open scrolling gridview with record closest to system date using FirstDisplayedScrollingRowIndex

I have a simple gridview with select records which include a date field.  The records include dates both before and after the system date, which are actually dated items entered for an entire year at a time.  I would like my scrolling gridview to open with the top record being the closest match to the current system date, even though there may not be an exact match (no record date matching system date).  But when the user opens the gridview, they will be at the top of the records whose date matches the current system date.  I am not an experienced programmer and have done most of the asp.net web site with Visual Studio 2008 and SQL Server.  I can code a bit but would need some help.  I am pretty sure what I want to do is with FirstDisplayedScrollingRowIndex, but I am not sure how.

Thanks for any help.
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

You have a confusing array of clues:

1) WinForms grid = DataGridView (not GridView)

2) You added this to ASP.NET (which would indicate GridView)

3) You mentioned FirstDisplayedScrollingRowIndex, which applies to DataGridView.

4) You mentioned "ASP.NET web site".

Question clarity, and usable clues make it easier for experts to help get a question answered.

Avatar of hconant

ASKER

I also said, "I am not an experienced programmer," which is obvious.  Just the same, you have actually shed some light on this and I will try to clarrify the confusion I created.
This is a simple web site I created using Visual Studio 2008.  I am utilizing asp.net controls and the pages are *.aspx.  The view, form, or whatever is a gridview, not a datagridview.  I didn't even know the difference.  I take it from your comment that the FirstDisplayedScrollingRowIndex will not work with what I currently have?  As far as your #4, I am not sure what I should clarrify about that.  The site address is http://blockislandschool.net.  The page i am working on is the Calendar Monthly.  There are only a couple of records at this time since we are just developing this.  But when the DB gets larger, the datagrid will be a hassle because someone just wanting current events would have to scrool through the entire years events.  We choose t his format because it is easy for authorized users to edit and insert.  That is what the "edit" link does.  If there is an easier way that would be fine.  This is just a student project for our small school.
Thanks for your help
Just confirming that we are talking about a GridView and ASP.NET is enough clarification for now.

Are you talking about a GridView in a scrolling <div> element?  If you want to select a row, then you would need to set SelectedIndex to the row index.
Avatar of hconant

ASKER

Yes, it is a GridView in a scrolling div element.  I will read up a bit to learn about the SelectedIndex and row index.  Currently I just use the SELECT statement in SQL query for the records I want, and set the sort order the same way, so in this case it sorts by date which is one of the fields. I am not familiar with the entire indexing situation so I guess I need to read up on that.
Are you using any paging, because I believe that will be confused with the SelectedIndex?
Avatar of hconant

ASKER

No paging.
I believe that setting GridView.SelectedIndex should be what you are after.
Avatar of hconant

ASKER

Can you expand upon that a bit?  I do not see how to utilize that in my situation, understanding that I have very little experience in programming.
Thanks
ASKER CERTIFIED SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial