473,395 Members | 1,658 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Datagrid Position of New Line

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

Dec 2 '05 #1
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

Dec 2 '05 #2
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

Dec 2 '05 #3
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

Dec 2 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
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...
2
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...
2
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...
8
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...
9
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....
4
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...
5
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...
1
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...
6
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
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...
0
marktang
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,...
0
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...
0
jinu1996
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...
0
tracyyun
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.