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.Sql Client.SqlConne ction
Dim MyCommand As System.Data.Sql Client.SqlDataA dapter
MyConnection = New
System.Data.Sql Client.SqlConne ction(Configura tionSettings.Ap pSettings("Conn S
tr"))
MyCommand = New System.Data.Sql Client.SqlDataA dapter("SELECT * FROM tblLog",
MyConnection)
DS = New DataSet
MyCommand.Fill( DS, "Log")
MyDataGrid.Data Source = DS.Tables("Log" ).DefaultView
MyDataGrid.Data Bind()
Thanks,
Ali 7 3555
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" <IH*******@sapm 123.com> wrote in message
news:en******** ******@tk2msftn gp13.phx.gbl... 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.Sql Client.SqlConne ction Dim MyCommand As System.Data.Sql Client.SqlDataA dapter
MyConnection = New
System.Data.Sql Client.SqlConne ction(Configura tionSettings.Ap pSettings("Conn S tr")) MyCommand = New System.Data.Sql Client.SqlDataA dapter("SELECT * FROM
tblLog", MyConnection)
DS = New DataSet MyCommand.Fill( DS, "Log")
MyDataGrid.Data Source = DS.Tables("Log" ).DefaultView MyDataGrid.Data Bind() Thanks, Ali
Hi Ali,
Thank you for posting to the MSDN newsgroups.
Based on my research and experience, I suggest you try the following
walkthrough on your side. Can you reproduce the same problem with it?
Walkthrough: Using a DataGrid Web Control to Read and Write Data http://msdn.microsoft.com/library/de...us/vbcon/html/
vbwlkwalkthroug husingdatagridw ebcontroltoread writedata.asp
I hope it helps.
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.
Does the button trigger a postback? You can check that by putting a break point at the databind statement.
Is the Datagrid property EnableViewState set =true? That could cause your symptoms.
"A.M" <IH*******@sapm 123.com> wrote in message news:ud******** ******@TK2MSFTN GP12.phx.gbl... Thank you Jacob for replay.
The article you refered me to, is not my case.
Here is may case:
I have a button and a datagrid in a page. The button is outside the datagrid. when i click the button, it chages the data behind the datagrid. As i mentioned in my post I DO NOT CHECK IsPostBack to supply data for datagrid. So Page_Load always supplay data for dataset and datagrid.
And my problem is:
After clicking the button, Datagrid remains unchanged. To update the datagrid, I have to press IE5 refresh button.
The summary of my question: How can i make a datagrid to refresh or re-read it's data.
Regards, Ali "Jacob Yang [MSFT]" <ji***@online.m icrosoft.com> wrote in message news:Dp******** *****@cpmsftngx a06.phx.gbl... Hi Ali,
Thank you for posting to the MSDN newsgroups.
Based on my research and experience, I suggest you try the following walkthrough on your side. Can you reproduce the same problem with it?
Walkthrough: Using a DataGrid Web Control to Read and Write Data http://msdn.microsoft.com/library/de...us/vbcon/html/ vbwlkwalkthroug husingdatagridw ebcontroltoread writedata.asp
I hope it helps.
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.
The button does trigges postback, and EnableViewState set =False (not true)
I disabled EnableViewState to have datagrid updated on every postback.
Thanks
Ali
"Gavin Jacobs" <no*********@in hell.com> wrote in message
news:OQ******** ******@tk2msftn gp13.phx.gbl... Does the button trigger a postback? You can check that by putting a break
point at the databind statement. Is the Datagrid property EnableViewState set =true? That could cause your
symptoms.
"A.M" <IH*******@sapm 123.com> wrote in message
news:ud******** ******@TK2MSFTN GP12.phx.gbl... Thank you Jacob for replay.
The article you refered me to, is not my case.
Here is may case:
I have a button and a datagrid in a page. The button is outside the datagrid. when i click the button, it chages the data behind the datagrid. As i mentioned in my post I DO NOT CHECK IsPostBack to supply data for datagrid. So Page_Load always supplay data for dataset and datagrid.
And my problem is:
After clicking the button, Datagrid remains unchanged. To update the datagrid, I have to press IE5 refresh button.
The summary of my question: How can i make a datagrid to refresh or re-read it's data.
Regards, Ali "Jacob Yang [MSFT]" <ji***@online.m icrosoft.com> wrote in message news:Dp******** *****@cpmsftngx a06.phx.gbl... Hi Ali,
Thank you for posting to the MSDN newsgroups.
Based on my research and experience, I suggest you try the following walkthrough on your side. Can you reproduce the same problem with it?
Walkthrough: Using a DataGrid Web Control to Read and Write Data http://msdn.microsoft.com/library/de...us/vbcon/html/ vbwlkwalkthroug husingdatagridw ebcontroltoread writedata.asp
I hope it helps.
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.
Hi Ali,
I am trying to reproduce the problem on my side now. Would you please post
the code of the button click? I certainly appreciate your 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.
Hi Ali,
Based on my research and experience, I would like to share the following
information with you.
This issue exists because the data binding to the datagrid (in page_load
event in this case) occurs before the event that responses to the postback
event (button_click event in this case). That is, when the data binding
occurs, the update to the database has not happened. In other words, the
data bound to the datagrid was still the old data.
The page lifecycle on every request is as follows:
1. Instantiate
2. Initialize
3. TrackViewState
4. LoadViewState (postback)
5. Load postback data (postback, IPostBackDataha ndler.LoadPostd ata)
6. Load
7. Load postback data for dynamical controls added on Page_Load
8. Raise Changed Events (postback,
IPostBackDataha ndler.RaisePost DataChanged)
9. Raise postback event (postback,
IPostBackEventH andler.RaisePos tBackEvent)
10.PreRender
11. SaveViewState
12. Render
13. Unload
14. Dispose
According to the page lifecycle, the data binding occurs in step 6,
however, the data changing to the database occurs in step 9. The changes
can only be reflected to the datagrid in next postback.
To overcome this problem, we should re-do the data bind after the data
changing was submitted to the database. In this case, we can do it in the
end of the button_click event.
In addition, to avoid the unnecessary data binding, we should encapsulate
the data binding operation in page_load event inside the IsPostBack
conditional statement.
For more info on page lifecycle, please refer to the article at http://aspalliance.com/articleViewer...=134&vId=&pId=
Does it answer your question? If I have misunderstood your concern, please
feel free to let me know.
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,
That helped me.
Thank you very much,
Ali
"Jacob Yang [MSFT]" <ji***@online.m icrosoft.com> wrote in message
news:OS******** ******@cpmsftng xa06.phx.gbl... Hi Ali,
Based on my research and experience, I would like to share the following information with you.
This issue exists because the data binding to the datagrid (in page_load event in this case) occurs before the event that responses to the postback event (button_click event in this case). That is, when the data binding occurs, the update to the database has not happened. In other words, the data bound to the datagrid was still the old data.
The page lifecycle on every request is as follows:
1. Instantiate 2. Initialize 3. TrackViewState 4. LoadViewState (postback) 5. Load postback data (postback, IPostBackDataha ndler.LoadPostd ata) 6. Load 7. Load postback data for dynamical controls added on Page_Load 8. Raise Changed Events (postback, IPostBackDataha ndler.RaisePost DataChanged) 9. Raise postback event (postback, IPostBackEventH andler.RaisePos tBackEvent) 10.PreRender 11. SaveViewState 12. Render 13. Unload 14. Dispose
According to the page lifecycle, the data binding occurs in step 6, however, the data changing to the database occurs in step 9. The changes can only be reflected to the datagrid in next postback.
To overcome this problem, we should re-do the data bind after the data changing was submitted to the database. In this case, we can do it in the end of the button_click event.
In addition, to avoid the unnecessary data binding, we should encapsulate the data binding operation in page_load event inside the IsPostBack conditional statement.
For more info on page lifecycle, please refer to the article at http://aspalliance.com/articleViewer...=134&vId=&pId=
Does it answer your question? If I have misunderstood your concern, please feel free to let me know.
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. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: msnews |
last post by:
Hi --
I'm very, very new to ASP.Net, and I've been trying for several days to
figure out how to update a datagrid AND refresh it on the client side so
that the page doesn't refresh. I've torn my code apart over and over each
time I tried what I thought would be the code that would solve my problem.
Maybe I'm going down the completely wrong path here. Essentially,
here is an explanation of my ASP.NET webform application and what I
want...
|
by: Jim Heavey |
last post by:
Trying to figure out the technique which should be used
to add rows to a datagrid. I am thinking that I would
want an "Add" button on the footer, but I am not quite
sure how to do that. Is that the best method? Do you
have a sample of how to do this?
|
by: Rod |
last post by:
I posted a message to this group yesterday asking how to pass parameters to
a web form that is the source of an IFrame on a parent web form. I've
gotten my answer, and it works. Thanks!
Now I have a different problem. The web form that is in the IFrame has a
DataGrid in it. I have a button column in it which I use to trigger the
deletion of the row in the database, and I want it to also reflect that
deletion in the data grid. The...
|
by: Mark Rae |
last post by:
I've inherited an ASP.NET app and have been asked to fix the following
problem with a page which is used to display and/or delete records from a
database. When the page loads, it displays a list of the 26 letters of the
alphabet as hyperlinks which the users then click to return records
beginning with that letter, displayed in a DataGrid. The first column of the
DataGrid contains a LinkButton which, when clicked, calls the Delete method
of...
|
by: Tom |
last post by:
I have an ASP.NET web page coded in VB.NET (2003). That web page has a
dropdown box on it which is loaded during the page_load event. When the user
drops this down and selects a data item, the code reads the database (based
upon what they selected, of course) and then loads the appropriate data into
the grid for display.
Now, however, I need to have the grid 'refreshed' at certain intervals. For
instance, if they leave the browser page...
| |
by: b_naick |
last post by:
In my Page_load I call a function called ShowUsers if its not a
postback. i.e
if (!Page.IsPostBack) {
ShowUsers();
}
ShowUsers reads a db table, and binds the reader to a datagrid.
On the page I also have some textbox fields - userid, name, email etc,
|
by: tshad |
last post by:
Is there a way to carry data that I have already read from the datagrid from
page to page?
I am looking at my Datagrid that I page through and when the user says get
the next page, I have to go to the database to get the next page. Is there
a way to use the dataset to allow us to read back and forth in it instead of
going back to the database to get it?
Thanks,
|
by: Jennyfer J Barco |
last post by:
Hello I have a datagrid and a linkbuttom in the datagrid that says Picture,
every time I click on the link "Picture" my program opens a popup window
showing a picture of the item the selected and information about the item.
On the html of the datagrid I have the following:
OnItemCommand="Grid_CartCommand" OnItemCreated="DataGrid_ItemCreated".
My VB functions are the following:
Sub DataGrid_ItemCreated(ByVal Sender As Object, ByVal e As...
|
by: rn5a |
last post by:
A Form has a DataGrid which displays records from a SQL Server 2005 DB
table. Users can modify the records using this DataGrid for which I am
using EditCommandColumn in the DataGrid. This is the code:
<script runat="server">
Dim sqlConn As New SqlConnection(".....")
Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs)
If Not (Page.IsPostBack) Then
FillDataGrid()
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |