In ASP.NET 1.1, I have SmartNavigation turned on so that the user's focus
will remain on the line in the datagrid they choose to edit.
When the user chooses to add a new line in the datagrid, rather than only
show that line, I'm displaying all items in the datagrid, with the new line
at the bottom.
With grdResults
' Set editing on last row
.EditItemIndex = .Items.Count
.DataSource = ds
.DataBind()
End With
This is fine if the number of items in the grid doesn't go beyond a page.
After that, the new line is not the focus, and the user needs to scroll down
the page to access the new line. How can I set the focus to that new line?
Here is my code in the Page_Load event:
If Not Page.IsPostBack Then
Try
Me.LoadGrid()
Catch ex As Exception
ShowMessageBox(Me, ex.Message)
End Try
End If 3 2307
If your datagrid has more than one page and you want the last page to be
displayed, calculate the last page number by dividing
grdResults.Items.Count/grdResults.PageSize then set the
grdResults.CurrentPageIndex to that number before doing the DataBind and
after you set the EditItemIndex to the Items.Count.
--
HTH,
Phillip Williams http://www.societopia.net http://www.webswapp.com
"Richard" wrote: In ASP.NET 1.1, I have SmartNavigation turned on so that the user's focus will remain on the line in the datagrid they choose to edit.
When the user chooses to add a new line in the datagrid, rather than only show that line, I'm displaying all items in the datagrid, with the new line at the bottom. With grdResults ' Set editing on last row .EditItemIndex = .Items.Count .DataSource = ds .DataBind() End With
This is fine if the number of items in the grid doesn't go beyond a page. After that, the new line is not the focus, and the user needs to scroll down the page to access the new line. How can I set the focus to that new line? Here is my code in the Page_Load event: If Not Page.IsPostBack Then Try Me.LoadGrid()
Catch ex As Exception ShowMessageBox(Me, ex.Message) End Try End If
Thanks Phillip, but I'm not using datagrid paging. I just need to know how to
set focus to the blank datagrid row at the bottom of the web form. If the
grid has only a few items, this isn't an issue because the user can see it
without scrolling down the web page. But when the grid has say 25 items, and
the user wants to create a new item, the last row is out of view until the
user scrolls vertically.
"Phillip Williams" wrote: If your datagrid has more than one page and you want the last page to be displayed, calculate the last page number by dividing grdResults.Items.Count/grdResults.PageSize then set the grdResults.CurrentPageIndex to that number before doing the DataBind and after you set the EditItemIndex to the Items.Count. -- HTH, Phillip Williams http://www.societopia.net http://www.webswapp.com
"Richard" wrote:
In ASP.NET 1.1, I have SmartNavigation turned on so that the user's focus will remain on the line in the datagrid they choose to edit.
When the user chooses to add a new line in the datagrid, rather than only show that line, I'm displaying all items in the datagrid, with the new line at the bottom. With grdResults ' Set editing on last row .EditItemIndex = .Items.Count .DataSource = ds .DataBind() End With
This is fine if the number of items in the grid doesn't go beyond a page. After that, the new line is not the focus, and the user needs to scroll down the page to access the new line. How can I set the focus to that new line? Here is my code in the Page_Load event: If Not Page.IsPostBack Then Try Me.LoadGrid()
Catch ex As Exception ShowMessageBox(Me, ex.Message) End Try End If
Hi Richard,
Assuming that the datagrid is the last element on the page, you might add
the following line after the DataBind step:
Page.RegisterStartupScript("ScrollTop", "<script
language='JavaScript'>document.body.scrollTop =100000;</script>")
Where 100000 is an arbitrary large number that would cause the browser to
scroll to the end of the page.
--
HTH,
Phillip Williams http://www.societopia.net http://www.webswapp.com
"Richard" wrote: Thanks Phillip, but I'm not using datagrid paging. I just need to know how to set focus to the blank datagrid row at the bottom of the web form. If the grid has only a few items, this isn't an issue because the user can see it without scrolling down the web page. But when the grid has say 25 items, and the user wants to create a new item, the last row is out of view until the user scrolls vertically.
"Phillip Williams" wrote:
If your datagrid has more than one page and you want the last page to be displayed, calculate the last page number by dividing grdResults.Items.Count/grdResults.PageSize then set the grdResults.CurrentPageIndex to that number before doing the DataBind and after you set the EditItemIndex to the Items.Count. -- HTH, Phillip Williams http://www.societopia.net http://www.webswapp.com
"Richard" wrote:
In ASP.NET 1.1, I have SmartNavigation turned on so that the user's focus will remain on the line in the datagrid they choose to edit.
When the user chooses to add a new line in the datagrid, rather than only show that line, I'm displaying all items in the datagrid, with the new line at the bottom. With grdResults ' Set editing on last row .EditItemIndex = .Items.Count .DataSource = ds .DataBind() End With
This is fine if the number of items in the grid doesn't go beyond a page. After that, the new line is not the focus, and the user needs to scroll down the page to access the new line. How can I set the focus to that new line? Here is my code in the Page_Load event: If Not Page.IsPostBack Then Try Me.LoadGrid()
Catch ex As Exception ShowMessageBox(Me, ex.Message) End Try End If This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Stephen |
last post by:
I've got a datagrid with a remove button and I would like to add some code in
the code behind page so as whenthe button is clicked the corresponding row in
the datagrid is removed. The Datagrid is...
|
by: Chris Plowman |
last post by:
Hi all,
I was wondering if anyone can help me with a really annoying problem I have
been having. I made a derived datagrid class that will select the row when
a user clicks anywhere on a cell...
|
by: VMI |
last post by:
Hi,
I have a Windows datagrid that's attached to a filled datatable. The grid
also has a tablestyle. Since the data from the grid comes from a
datatatable, how can I retrieve the data from a...
|
by: Strahimir Antoljak |
last post by:
I bound a DataGrid to a table (I tried with a DataView too).
I removed the row from the table, and then inserted a new
row at the same row index. the table gets the row to the
right position, but...
|
by: John Hernry |
last post by:
I have been watching the dotnet newsgroups for a couple of weeks now and
scouring the net looking for a solution to my datagrid find functionality.
With no luck. I am hoping that you can help me....
|
by: Jeff User |
last post by:
Hi
I tryed to solve this problem over in the framework.asp group, but
still am having trouble. Hope someone here can help.
using .net 1.1, VS 2003 and C#
I have an asp.DataGrid control with a...
|
by: Antonio |
last post by:
Hello, everyone.
Is there a way to not display a certain value in a datagrid cell?
I have a datagrid for subscriptions and ebooks and if there isn't an e-book
listed, the value from the...
|
by: DaveS |
last post by:
I am trying to capture the mouse click position in a datagrid but I get the
following compilation error:
Compiler Error Message: BC30002: Type 'System.Windows.Forms.MouseEventArgs'
is not...
|
by: slinky |
last post by:
I found the following code to transfer datagrid data to an Excel file.
Is this written in C#?... I'm a vb.netter. I'm just not sure where to
place the code to experiment on it. Should I place it in...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |