Gridview is not refreshing

Discussion in 'ASP .Net' started by shapper, Sep 20, 2007.

  1. shapper

    shapper Guest

    Hello,

    I have a GridView which is being created at runtime. When I delete a
    row the grid is only updated after i make refresh on my browser? Why?

    I have the gvPosts.Databind() on my RowDeleting event.

    Maybe the order and placement of my gridview properties and bind is
    wrong through my gridview events.

    Could someone, please, check this out? Here are the 3 events I am
    using:

    Protected Sub gvPosts_Init(ByVal sender As Object, ByVal e As
    EventArgs) Handles gvPosts.Init

    gvPosts.AutoGenerateColumns = False
    gvPosts.ID = "gvPosts"

    Dim tfPost As New TemplateField
    tfPost.ItemTemplate = New tfPost(ListItemType.Item)
    gvPosts.Columns.Add(tfPost)

    End Sub ' gvPosts_Init

    Private Sub gvPosts_Load(ByVal sender As Object, ByVal e As
    System.EventArgs) Handles gvPosts.Load

    Dim mc As New MyClass
    With gvPosts
    .DataSource = mc.GetData
    .DataKeyNames = New String() {"Id"}
    .DataBind()
    End With

    End Sub ' gvPosts_Load

    Protected Sub gvPosts_RowDeleting(ByVal sender As Object, ByVal e
    As GridViewDeleteEventArgs) Handles gvPosts.RowDeleting

    Dim mc As New MyClass
    mc.Delete(New
    Guid(gvPosts.DataKeys(e.RowIndex).Value.ToString()))
    gvPosts.DataBind()

    End Sub ' gvPosts_RowDeleting

    Any idea what I am doing wrong?

    Thanks,

    Miguel
     
    shapper, Sep 20, 2007
    #1
    1. Advertising

  2. shapper

    shapper Guest

    On Sep 20, 5:29 pm, shapper <> wrote:
    > Hello,
    >
    > I have a GridView which is being created at runtime. When I delete a
    > row the grid is only updated after i make refresh on my browser? Why?
    >
    > I have the gvPosts.Databind() on my RowDeleting event.
    >
    > Maybe the order and placement of my gridview properties and bind is
    > wrong through my gridview events.
    >
    > Could someone, please, check this out? Here are the 3 events I am
    > using:
    >
    > Protected Sub gvPosts_Init(ByVal sender As Object, ByVal e As
    > EventArgs) Handles gvPosts.Init
    >
    > gvPosts.AutoGenerateColumns = False
    > gvPosts.ID = "gvPosts"
    >
    > Dim tfPost As New TemplateField
    > tfPost.ItemTemplate = New tfPost(ListItemType.Item)
    > gvPosts.Columns.Add(tfPost)
    >
    > End Sub ' gvPosts_Init
    >
    > Private Sub gvPosts_Load(ByVal sender As Object, ByVal e As
    > System.EventArgs) Handles gvPosts.Load
    >
    > Dim mc As New MyClass
    > With gvPosts
    > .DataSource = mc.GetData
    > .DataKeyNames = New String() {"Id"}
    > .DataBind()
    > End With
    >
    > End Sub ' gvPosts_Load
    >
    > Protected Sub gvPosts_RowDeleting(ByVal sender As Object, ByVal e
    > As GridViewDeleteEventArgs) Handles gvPosts.RowDeleting
    >
    > Dim mc As New MyClass
    > mc.Delete(New
    > Guid(gvPosts.DataKeys(e.RowIndex).Value.ToString()))
    > gvPosts.DataBind()
    >
    > End Sub ' gvPosts_RowDeleting
    >
    > Any idea what I am doing wrong?
    >
    > Thanks,
    >
    > Miguel


    Please, anyone?
     
    shapper, Sep 20, 2007
    #2
    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. H5N1
    Replies:
    0
    Views:
    2,721
  2. Mike Grace
    Replies:
    1
    Views:
    1,925
    Brock Allen
    May 12, 2006
  3. Harlan Messinger

    Self-refreshing and non-self-refreshing controls

    Harlan Messinger, Aug 4, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    460
    =?Utf-8?B?Y2xpY2tvbg==?=
    Aug 4, 2006
  4. Loading name...

    refreshing GridView

    Loading name..., Aug 28, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    3,070
    Eliyahu Goldin
    Aug 28, 2006
  5. Harlan Messinger

    Self-refreshing and non-self-refreshing controls

    Harlan Messinger, Aug 3, 2006, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    187
    Harlan Messinger
    Aug 3, 2006
Loading...

Share This Page