473,386 Members | 1,708 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,386 software developers and data experts.

Setting Focus on Edit Row in Datagrid - how do I reference new clientid name???

Hello and Good Day. REALLY LOST.

Running ASP.NET 1.1

Becuase I think I'm using my own controls smartnavigation does not
appear to work for me.

Stardard issue: I've got a datagrid thats displaying pages and pages of
rows. When I edit some row below pages 1 the post refreshes back to
page one, requiring me to page down to do the input.

I have found some C# code that looks promising, but can't seem to make
it work in VB ..

I'm just taking shots in the dark now.

When I attempt to execute this code I get javascript error that
responsible is not defined. when I view source, ofcourse the datagrid
has used clientid to rename ids.. something like:
id="UserGrid__ctl2_responsible"

Below is my really bad attempt at getting this to work:

<beginning of code>

Public Sub UserGrid_Edit (Source As Object, E As
DataGridCommandEventArgs)
UserGrid.EditItemIndex = E.Item.ItemIndex
BindData()

' the below code is to force dropdown to display preset value in
database first so
'update does not take the wrong value!

'make dropdowns remember current value
Dim ddlResponsible As DropDownList =
UserGrid.Items(e.Item.ItemIndex).FindControl("resp onsible")
Dim colIndex As Integer = 2
Dim resp As String = CType(e.Item.Cells(colIndex).Controls(1),
Label).Text.Trim
For I As Integer = 0 To ddlResponsible.Items.Count - 1
If ddlResponsible.Items(I).Text.Trim.Equals(resp) Then
ddlResponsible.SelectedIndex = I
Exit For
End If
Next

Dim ddlstatus As DropDownList =
UserGrid.Items(e.Item.ItemIndex).FindControl("stat us")
Dim colIndexb As Integer = 3
Dim stat As String = CType(e.Item.Cells(colIndexb).Controls(1),
Label).Text.Trim
For I As Integer = 0 To ddlstatus.Items.Count - 1
If ddlstatus.Items(I).Text.Trim.Equals(stat) Then
ddlstatus.SelectedIndex = I
Exit For
End If
Next

'here's where trying to focus, but can't figure out how to address the
new id

Dim strBuilder As StringBuilder = New StringBuilder()
strBuilder.Append("<script language='javascript'>function
window.onload(){")
strBuilder.Append("
document.elements(responsible.clientid).focus();")
strBuilder.Append("}"+chr(60)+"/script>")
RegisterStartupScript("FR", strBuilder.ToString)
End Sub

<end of code>

And, while on the subject - is there any way in javascript to just go
to the second field? in this case its a dropdown select.
Here are my two senseless attempts.

<body onload="document.forms[0].fields[1].focus()">

does not work, nor does

<body onload="document.forms[0].elementsbyid((*responsible').focus()">
THANK YOU FOR ANY HELP OR INFORMATION!!!!

Nov 19 '05 #1
2 1953
I have a sample in VB that sets the focus to the edit box:
http://www.webswapp.com/webswapp.aspx?i=11

---
www.societopia.net

"ja***@cyberpine.com" wrote:
Hello and Good Day. REALLY LOST.

Running ASP.NET 1.1

Becuase I think I'm using my own controls smartnavigation does not
appear to work for me.

Stardard issue: I've got a datagrid thats displaying pages and pages of
rows. When I edit some row below pages 1 the post refreshes back to
page one, requiring me to page down to do the input.

I have found some C# code that looks promising, but can't seem to make
it work in VB ..

I'm just taking shots in the dark now.

When I attempt to execute this code I get javascript error that
responsible is not defined. when I view source, ofcourse the datagrid
has used clientid to rename ids.. something like:
id="UserGrid__ctl2_responsible"

Below is my really bad attempt at getting this to work:

<beginning of code>

Public Sub UserGrid_Edit (Source As Object, E As
DataGridCommandEventArgs)
UserGrid.EditItemIndex = E.Item.ItemIndex
BindData()

' the below code is to force dropdown to display preset value in
database first so
'update does not take the wrong value!

'make dropdowns remember current value
Dim ddlResponsible As DropDownList =
UserGrid.Items(e.Item.ItemIndex).FindControl("resp onsible")
Dim colIndex As Integer = 2
Dim resp As String = CType(e.Item.Cells(colIndex).Controls(1),
Label).Text.Trim
For I As Integer = 0 To ddlResponsible.Items.Count - 1
If ddlResponsible.Items(I).Text.Trim.Equals(resp) Then
ddlResponsible.SelectedIndex = I
Exit For
End If
Next

Dim ddlstatus As DropDownList =
UserGrid.Items(e.Item.ItemIndex).FindControl("stat us")
Dim colIndexb As Integer = 3
Dim stat As String = CType(e.Item.Cells(colIndexb).Controls(1),
Label).Text.Trim
For I As Integer = 0 To ddlstatus.Items.Count - 1
If ddlstatus.Items(I).Text.Trim.Equals(stat) Then
ddlstatus.SelectedIndex = I
Exit For
End If
Next

'here's where trying to focus, but can't figure out how to address the
new id

Dim strBuilder As StringBuilder = New StringBuilder()
strBuilder.Append("<script language='javascript'>function
window.onload(){")
strBuilder.Append("
document.elements(responsible.clientid).focus();")
strBuilder.Append("}"+chr(60)+"/script>")
RegisterStartupScript("FR", strBuilder.ToString)
End Sub

<end of code>

And, while on the subject - is there any way in javascript to just go
to the second field? in this case its a dropdown select.
Here are my two senseless attempts.

<body onload="document.forms[0].fields[1].focus()">

does not work, nor does

<body onload="document.forms[0].elementsbyid((*responsible').focus()">
THANK YOU FOR ANY HELP OR INFORMATION!!!!

Nov 19 '05 #2
I have a sample in VB that sets the focus to the edit box:
http://www.webswapp.com/webswapp.aspx?i=11

---
www.societopia.net

"ja***@cyberpine.com" wrote:
Hello and Good Day. REALLY LOST.

Running ASP.NET 1.1

Becuase I think I'm using my own controls smartnavigation does not
appear to work for me.

Stardard issue: I've got a datagrid thats displaying pages and pages of
rows. When I edit some row below pages 1 the post refreshes back to
page one, requiring me to page down to do the input.

I have found some C# code that looks promising, but can't seem to make
it work in VB ..

I'm just taking shots in the dark now.

When I attempt to execute this code I get javascript error that
responsible is not defined. when I view source, ofcourse the datagrid
has used clientid to rename ids.. something like:
id="UserGrid__ctl2_responsible"

Below is my really bad attempt at getting this to work:

<beginning of code>

Public Sub UserGrid_Edit (Source As Object, E As
DataGridCommandEventArgs)
UserGrid.EditItemIndex = E.Item.ItemIndex
BindData()

' the below code is to force dropdown to display preset value in
database first so
'update does not take the wrong value!

'make dropdowns remember current value
Dim ddlResponsible As DropDownList =
UserGrid.Items(e.Item.ItemIndex).FindControl("resp onsible")
Dim colIndex As Integer = 2
Dim resp As String = CType(e.Item.Cells(colIndex).Controls(1),
Label).Text.Trim
For I As Integer = 0 To ddlResponsible.Items.Count - 1
If ddlResponsible.Items(I).Text.Trim.Equals(resp) Then
ddlResponsible.SelectedIndex = I
Exit For
End If
Next

Dim ddlstatus As DropDownList =
UserGrid.Items(e.Item.ItemIndex).FindControl("stat us")
Dim colIndexb As Integer = 3
Dim stat As String = CType(e.Item.Cells(colIndexb).Controls(1),
Label).Text.Trim
For I As Integer = 0 To ddlstatus.Items.Count - 1
If ddlstatus.Items(I).Text.Trim.Equals(stat) Then
ddlstatus.SelectedIndex = I
Exit For
End If
Next

'here's where trying to focus, but can't figure out how to address the
new id

Dim strBuilder As StringBuilder = New StringBuilder()
strBuilder.Append("<script language='javascript'>function
window.onload(){")
strBuilder.Append("
document.elements(responsible.clientid).focus();")
strBuilder.Append("}"+chr(60)+"/script>")
RegisterStartupScript("FR", strBuilder.ToString)
End Sub

<end of code>

And, while on the subject - is there any way in javascript to just go
to the second field? in this case its a dropdown select.
Here are my two senseless attempts.

<body onload="document.forms[0].fields[1].focus()">

does not work, nor does

<body onload="document.forms[0].elementsbyid((*responsible').focus()">
THANK YOU FOR ANY HELP OR INFORMATION!!!!

Nov 19 '05 #3

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

Similar topics

0
by: ED M. | last post by:
Hello all...I'm new to the board. I have a problem that I hope someone here might be able to solve for me. I am doing some clientside validation using Javascript. The text I am testing is...
0
by: Shravan | last post by:
Hi, I have a Windows Forms Custom DataGrid, which is put in a usercontrol, which on setting DataSource is setting focus to grid. The call stack for setting the focus is as follows. This is not...
0
by: JoRo | last post by:
I am working on a project where I want a very user-friendly interface. I have a datagrid of categories that uses the EditCommandColumn to do in-line editing of the category name. On the page is...
4
by: Mark Rae | last post by:
Hi, VS.NET 2003 on WinXPPro, both with all the latest patches and updates, etc... I've got a very simple WebForm which is used either to add a new record to a SQL Server database or edit a...
3
by: Nate Hekman | last post by:
I'm making a simple page with an edit box and a Submit button. When a user arrives at the page, I'd like the focus to be in the edit box. I can do it with javascript, but it seems to me there...
1
by: Bonj | last post by:
Hi I've got an ASP.NET datagrid control, and in the footer, there is a series of controls for typing in new values to add an item. e.g. <asp:DataGrid runat="Server".... > <Columns> ......
4
by: Jerry Camel | last post by:
Once the datalist is in edit mode and the text boxes and all happily appear, how can I force the textbox to be the control with focus, so the user can start editing without having to click the...
2
by: DC | last post by:
Hi, I am doing something like this in the ItemCreated event (ASP.Net 1.1): DataGridItem pagerRow = e.Item; TableCell pagerCell = pagerRow.Cells; Control addedControl = new Control();...
8
by: Brad Isaacs | last post by:
Good morning friends, I am working with Visual Studio 2005, ASP.NET 2.0 I am working with the Login controls provided my .NET 2.0, trying to make the Login1 control UserName textbox obtain...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.