.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Post New Web Links

How to refresh data in the DataGridView by using a Timer?

Posted By:      Posted Date: September 13, 2010    Points: 0   Category :ASP.Net
Hi all I am refreshing my DataGridView by calling using the code below: protected void Timer1_Tick(object sender, EventArgs e) { UpdatedTime.Text = DateTime.Now.ToLongTimeString(); FillDataGridView(); } protected void FillDataGridView() { DataSet objDs = new DataSet(); SqlConnection myConnection = new SqlConnection(WebConfigurationManager.ConnectionStrings["Test"].ConnectionString); SqlDataAdapter myCommand; string select = "SELECT * FROM TableLogging"; myCommand = new SqlDataAdapter(select, myConnection); myCommand.SelectCommand.CommandType = CommandType.Text; myConnection.Open(); myCommand.Fill(objDs); GridView1.DataSource = objDs; GridView1.DataBind(); } However I want to use templates in the DataGridView like this: <asp:TemplateField HeaderText="InstanceID" SortExpression="InstanceID"> <ItemTemplate> <asp:Label ID="lblInstanceID" runat="server" Text='<%# Eval("instanceID") %>' /> </ItemTemplate> </asp:TemplateField> So I would NOT be calling FillDataGridView() from Timer1_Tick. My question is: what do I have to add inside Timer1_Tick so that it will refresh my DataGridView (the one with the templates) Thank you! 

View Complete Post

More Related Resource Links

Using AJAX timer to refresh data


I am writing a ASP.NET C# application and using a AJAX timer in order to refresh some if the data every couple of seconds.

Whenever the timer function is called, it looks like the whole page is rendered again. For example, I have a list of tabs, the selected tab is not selected anymore.

I need to keep the selected tab 'selected' after refresh.

How can I achieve that?
I am attaching the relevant code.

my aspx:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="test.aspx.cs" Inherits="InternalMonitorTool.test" %>

SQLCE 3.5 connection from multiple application, data refresh

I have a native application (wm 6.5) using oledb to connect to a database. *******************************************************************************   result=CoCreateInstance(CLSID_SQLSERVERCE_3_5,0,CLSCTX_INPROC_SERVER,IID_IDBInitialize, (void**)&database);   ... // set properties  database->Initialize(); ******************************************************************************* This part of the app simply queries a single table for all records (query wrapped in a transaction of it own). I believe it is recommended that you keep a single connection for as long as possible, and therefore just create a new session each time I query the table. There is a second application (c#) which my application executes and then waits for. It updates and inserts new records. when the c# app closes and I get control back, my app then runs another query to see if anything has changed. My issue is that, the only way I can get the updated data is to un-initialize and re-initialize the database (IDBInitialize) interface created above.  Is there some properties I should be setting on the session/database in order for this to work. Or do I really have to spawn a new connection for every query?   Thanks in advance. Dylan

datagridview add data a column at a time

How do I add to a datagridview a column at a time? I see at http://msdn.microsoft.com/en-us/library/5s3ce6k8.aspx that it is possible to do it a row at a time. I was looking for something similar.      

Need advice to display data in DataGridView, then edit dan save the data

I am Winform Beginner. To display data using DataGridView is ok with me. How the best way to select row in DataGridView, then edit and save. Did this DataGridView can editable? or Once row in DataGridView is selected, then popup another form to perform edit transaction. Really need advice and good example

How to refresh the data without having to click on F5?

Hi,My code:private void GetCardDetails() { // Update these variables to values whatever you are storing in your table // If you are storing as CARD NUMBER, update this Card Number Attribute Name to CARD NUMBER string strCardNumberAttributeName = "Credit card number"; // string strCardTypeAttributeName = "1"; string strExpiryDateAttributeName = "Expiry date"; MembershipUser myObject = Membership.GetUser(); string UserID = myObject.ProviderUserKey.ToString(); DataTable dtPaymentDetails = new DataTable(); string queryString = "SELECT tbl_payments.ID, tbl_PaymentDetails.AttributeName, tbl_PaymentDetails.Value, tbl_Payments.PaymentType FROM tbl_Payments INNER JOIN tbl_PaymentDetails ON tbl_Payments.ID = tbl_PaymentDetails.PaymentId WHERE ATTRIBUTENAME IN ('" + strCardNumberAttributeName + "','" + strExpiryDateAttributeName + "') AND (tbl_Payments.UserId = '" + UserID + "') AND (tbl_PaymentDetails.UserId = '" + UserID + "') ORDER BY tbl_Payments.PaymentType DESC"; using (SqlConnection connection = new SqlConnection(connectionString)) { SqlCommand command = new SqlCommand(queryString, connection); connection.Open();

Excel Services no refresh data & no error logs

Hi! I'm trying to publish an Excel workbook which loads data from SQL Server. The result is: no data loaded in the workbook and no error logged on Sharepoint logs. Notice that if I try to refresh the workbook in Office Excel all works fine! I try to set up Windows Authentication, None (to use unattended account) and with .odc file but with no result! The procedure I follow is: 1) create a new Excel file and create new data connection to the database (SQL Server 2008) 2) upload the file in the trusted file location 3) open the file in a web part and click on the "refresh all" button I used the same unattended account which I setup for this purpose with BCS and it works fine! I also try to set with PowerShell the Application ID created ("ES"): "set-spexcelserviceapplication -identity 6d871d92-19dd-4421-b33b-0012f9a5ea18 -unattendedaccountapplicationid ES" with no result. I noticed that the identity of the Excel Service application shown in the Central Administration isn't in the IIS Application Pool list: could it be the problem? I also tried to delete / re-create the application but the two IDs remains disequal! Have someone of you already worked with Excel Services and could give me any help? Thanx in advance, Elena

workbooks inside of sharePoint site has data refresh error


We have workbooks inside of our SharePoint site, using NTLM authentication and Excel Services connectors. They correctly display graphs when the page is first opened, but all of them throw an error when users try to trigger an update. The error message sayss "Excel. An error occurred during an attempt to establish a connection to the external data source. The following connections failed to refresh: [name of any data cube in use]. Learn more about data refresh." We are not using Power Pivot (which may make it easier, but is not authorised for use by our server administrators yet).

Refresh datagridview in windows form application


I am having a main which will have 2 controls namely treeview and datagridview . I will have a form to be opened when user selects an option from treeview. My treeview will be as follows





If i click on the text file that was child to the root i will show the content of that file. But what i need is if right click on child i will have an option as NEW and i will get a new form. If i enter some values and click on save i will save them to the text file which was provided in the treeview at the same time i would like to show the user in the datagridview when the second form gets hide. Like that i can have multiple child forms what ever data i give there in the forms that should be shown to datagridview when the child form gets closed or hide

Visio service data refresh help


I have created Visio 2010 diagram hwich gets the data from SQL 2008 server. vsd diagram works fine on the client, data is refreshed when I click Refresh from Visio 2010.

I have published it as vwd using "Share" option of Visio 2010 on SharePoint 2010 server in Shared Documents site library. It opens fine in browser, you see the diagram, but data is not refreshing, although I force it with dedicated SharePoint Refresh button on the top of the page. No errors, just the data is not updating.

SQL 2008 server is actually on the same Windows 2008 server where the SharePoint 2010 server is. The question is how it connects and works fine from the client PC but cant refresh the data on the server. I am admin on all boxes.

Do I need to publish ODC file on the SharePoint 2010 server too ?

Any help is appreciated.



How to Refresh Gridview data from update panel in specified time


hello frnds,

i have some search criteria.

after filling all criteria when i press search button the result arrives in gridview nw when searchbutton pressed after that every 20seconds i want 2 update gridview data which is in update panel

Insert data to ms access from datagridview using dataset


please give me sample code for insert data to MS ACCESS  from grid view using dataset

refresh stored data into table


hi all,

i have create a form in asp.net & C# using SQL server..

after i click save button data will stored in table..

if i click refresh in browser it save my data again into table..

what is the problem actually?

duplicate data on page refresh


I m working on ASP.Net database related project. I have one form including one Button, On ButtonClick I m inserting data into database.

It is working fine but when I m refreshing the page then again it is inserting same record into database.

I dont want this, so suggest me what  is the problem.

Thank's in advance.



Excel Services data refresh from SSAS: How to?


Hello everybody,

I know there's been several threads already on this topic, but I haven't been able to distill a solution to my particular situation. The problem is largely because of my ignorance on the SharePoint part, I'm afraid.

Anyway, here's the situation:

  • SharePoint 2010 Ent in Stand-Alone mode
  • Windows Server 2008
  • Analysis Services 2008 R2 on the same box
  • No windows domain, all people using the system are outside the company
  • All users are created as local windows users
  • We're using the msmdpump to allow access to Analysis Services
  • Excel 2010 is the client for SSAS
  • The user id and password are both stored in the ODC file
  • The user in the ODC is member of a role that allows read-access to the cube
  • The ODC is in a trusted location
  • Since I want Excel Services to use the connection string, the Authentication setting is set to None in the ODC

Now, if I publish an Excel Pivot table to SharePoint and the try to open it in the browser, the initially cached data is displayed. As soon as I try to refresh the data, I get a Data Refresh Failed error. I've been reading for two days straight, and I think I understand that I need to configure the unattended service account using the Secure Store Service.

This is where I'm getting confused. i

script in clientside but why it refresh data?


 i have textboxs like these



Sub tru02(ByVal sender As Object, ByVal e

visio services - can't get rid of data refresh error


keep getting this error message on trying to refresh data

"Viso services was unable to refresh external data connections in this web drawing because of changes in teh structure od an underlying data source. one or more columns in this data source have been deleted after this web drawing was last saved."

The underlying data source has not been changed and I have tried re-creating the visio web drawing from scratch - always this error!

any ideas on how to progress?



adhoc reporting - data doesn't refresh on date range change


I created an adhoc report model using SQL Server 2008 reporting services. I am using data from a SQL 2000 database sitting on a SQL 2000 server. I created reports with start date and end date parameters, everything worked fine.


Now my ad hoc report model uses a SQL 2000 database (this database is a replication of the database I was using)  sitting on a SQL 2008 server. When I change parameters like start date and end dates, data doesn’t refresh. It shows the same data for any date range.


Has anyone seen this problem? What could be done to fix the issue. Is there any setting on the SQL server to fix this?



ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend