Refreshing DataGrid in page_load

Discussion in 'ASP .Net Datagrid Control' started by A.M, Oct 30, 2003.

  1. A.M

    A.M Guest

    Hi,

    I want to refresh my DataGrid data on every postback.
    I have following code in Page_Load event, but after first page load, the
    DataGrid never gets refresh.

    Here is the code i have in Page_load (it works at first page_load):

    Dim DS As DataSet
    Dim MyConnection As System.Data.SqlClient.SqlConnection
    Dim MyCommand As System.Data.SqlClient.SqlDataAdapter

    MyConnection = New
    System.Data.SqlClient.SqlConnection(ConfigurationSettings.AppSettings("ConnS
    tr"))
    MyCommand = New System.Data.SqlClient.SqlDataAdapter("SELECT * FROM tblLog",
    MyConnection)

    DS = New DataSet
    MyCommand.Fill(DS, "Log")

    MyDataGrid.DataSource = DS.Tables("Log").DefaultView
    MyDataGrid.DataBind()



    Thanks,
    Ali
    A.M, Oct 30, 2003
    #1
    1. Advertising

  2. A.M

    Aaron @ PASC Guest

    Do you have the code incapsulated in a:

    If Not IsPostBack Then conditional? If so you would need to take the Fill
    and DataBind code outside of the conditional as well.

    Just a thought,
    Aaron


    "A.M" <> wrote in message
    news:...
    > Hi,
    >
    > I want to refresh my DataGrid data on every postback.
    > I have following code in Page_Load event, but after first page load, the
    > DataGrid never gets refresh.
    >
    > Here is the code i have in Page_load (it works at first page_load):
    >
    > Dim DS As DataSet
    > Dim MyConnection As System.Data.SqlClient.SqlConnection
    > Dim MyCommand As System.Data.SqlClient.SqlDataAdapter
    >
    > MyConnection = New
    >

    System.Data.SqlClient.SqlConnection(ConfigurationSettings.AppSettings("ConnS
    > tr"))
    > MyCommand = New System.Data.SqlClient.SqlDataAdapter("SELECT * FROM

    tblLog",
    > MyConnection)
    >
    > DS = New DataSet
    > MyCommand.Fill(DS, "Log")
    >
    > MyDataGrid.DataSource = DS.Tables("Log").DefaultView
    > MyDataGrid.DataBind()
    >
    >
    >
    > Thanks,
    > Ali
    >
    >
    Aaron @ PASC, Oct 30, 2003
    #2
    1. Advertising

  3. Hi Ali,

    I noticed that you posted the same question in the
    microsoft.public.dotnet.framework.aspnet group. I have replied you on that
    thread. Please check it when you have time.

    Best regards,

    Jacob Yang
    Microsoft Online Partner Support
    Get Secure! ┬ĘC www.microsoft.com/security
    This posting is provided "as is" with no warranties and confers no rights.
    Jacob Yang [MSFT], Oct 31, 2003
    #3
    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. A.M
    Replies:
    7
    Views:
    2,154
  2. bminder
    Replies:
    1
    Views:
    2,154
    nfedin
    Feb 23, 2004
  3. z. f.
    Replies:
    0
    Views:
    550
    z. f.
    Oct 19, 2004
  4. Harlan Messinger

    Self-refreshing and non-self-refreshing controls

    Harlan Messinger, Aug 4, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    445
    =?Utf-8?B?Y2xpY2tvbg==?=
    Aug 4, 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:
    180
    Harlan Messinger
    Aug 3, 2006
Loading...

Share This Page