Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / July 2005

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
jason@cyberpine.com - 15 Jul 2005 05:04 GMT
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("responsible")
    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("status")
    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!!!!
societopia.net - 15 Jul 2005 21:16 GMT
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

> Hello and Good Day. REALLY LOST.
>
[quoted text clipped - 81 lines]
>
> THANK YOU FOR ANY HELP OR INFORMATION!!!!

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.