473,769 Members | 4,584 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2326
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.Item s.Count/grdResults.Page Size then set the
grdResults.Curr entPageIndex 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.Item s.Count/grdResults.Page Size then set the
grdResults.Curr entPageIndex 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.RegisterSt artupScript("Sc rollTop", "<script
language='JavaS cript'>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.Item s.Count/grdResults.Page Size then set the
grdResults.Curr entPageIndex 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
3055
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 populated by the items in an arraylist shown in the code below. When the button is clicked I would also like the code to remove the items from the Arraylist. I've very little experience working with datagrids and arraylists so im finding this...
2
9926
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 (multi-select without modifier keys). I got that working fine, but I also wanted to keep rows selected after a sort, which I do by storing the row's id in an arraylist. The idea was to do the sort and then go back and re-select the rows with that...
2
1723
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 specific table row once a user clicks on a grid row? I already have the code that lets me know what grid row the user clicked on, but, for example, if I want to retrieve the value of the 5th column in the grid, I'm currently using myGrid.ToString()....
8
2028
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 the bound DataGrid does not pick up and appends the inserted row at the bottom of the grid, not the right position?!? Any ideas how to make the DataGrid pick up the changes done in the table - to show the inserted row at the right position?
9
3378
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. I am an old VB6 coder used to using Sheridan controls, and I am just starting to learn the .net world. I am upgrading my music catalogue database, where the data is stored in an Access mdb file.
4
2137
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 Delete button on the end of each row. I am unable to gain access to the event when the button is clicked. I don't fully understand how the click gets connected to the C# code,
5
3154
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 database (SQL) is "Null/No Set Dummy Row". Is there a way I can suppress that data in the datagrid? Thanks,
1
1714
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 defined. Source Error: Line 84: Private myCheckBoxCol As Integer = 0 'my checkbox column Line 85:
6
2738
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 the event handler for a form button. Is there other ways to accomplish this? I looked at some on the web and usergroups, but was confused as to the functioning. BTW my datagrid is enclosed in a <div></divfor ease of scrolling if that would...
0
9423
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10045
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9863
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8870
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7406
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5298
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3561
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.