why does the detailsview not get the focus?

Discussion in 'ASP .Net' started by bob, Oct 18, 2006.

  1. bob

    bob Guest

    Hi,


    When running this code, the detailsview doesn't get the focus.
    The fields of the detailsview are programmatically created. I use therefore
    the dtreader.FieldCount.

    What's wrong with this code?
    Thanks for helping.
    Bob


    Here part of the code:

    in aspx file:
    ---------
    ....
    <asp:SqlDataSource ID="SqlDataSource1" runat="server"
    ConnectionString="Provider = Microsoft.Jet.OLEDB.4.0; Data Source =
    c:mytable"> </asp:SqlDataSource>
    <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False"
    CellPadding="4" DataSourceID="SqlDataSource1" DefaultMode="Insert">
    <Fields>
    <asp:CommandField ShowInsertButton="True" InsertText="Bewaren"
    CancelText="Opnieuw"/>
    </Fields>
    </asp:DetailsView>

    in aspx.vb file:
    -------------
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As
    System.EventArgs) Handles Me.Load
    .....
    sql = "select * from mytable;"
    comd = New OleDbCommand(sql, oConnection)
    dtreader = comd.ExecuteReader
    nfield = dtreader.FieldCount
    Dim bf(nfield) As BoundField
    For i = 1 To nfield
    bf(i) = New BoundField
    bf(i).DataField = "fld" & i
    DetailsView1.Fields.Add(bf(i))
    Next
    dtreader.Close()
    .....

    end sub

    Protected Sub DetailsView1_ItemCreated(ByVal sender As Object, ByVal e As
    System.EventArgs) Handles DetailsView1.ItemCreated
    DetailsView1.Focus()
    End Sub
    bob, Oct 18, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mr. SweatyFinger
    Replies:
    2
    Views:
    1,769
    Smokey Grindel
    Dec 2, 2006
  2. bob

    why does the detailsview not get the focus?

    bob, Oct 18, 2006, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    747
  3. bob

    why does the detailsview not get the focus?

    bob, Oct 18, 2006, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    115
  4. Replies:
    2
    Views:
    330
    Thomas 'PointedEars' Lahn
    Jun 6, 2005
  5. Roger
    Replies:
    3
    Views:
    311
Loading...

Share This Page