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

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

UpdatePanel, GridView and Timer controls used together - OnTick() and DataBind

Posted By:      Posted Date: October 11, 2010    Points: 0   Category :ASP.Net


I am currently working on a page that contains a GridView control which is bound to an ObjectDataSource control.  The ObjectDataSource invokes a method on a DAO layer class that returns a DataTable and all is working just fine.  Paging and Sorting are enabled and work ok as well.  I have "wrapped" the GridView control inside an <UpdatePanel><ContentTemplate> construct and now the Paging and Sorting occur w/o the Page reload as expected - still no problem. 

However, now I want to have the GridView simply refresh itself every 5 to 10 seconds so I placed a Timer control w/ an interval of 5000 milliseconds INSIDE the UpdatePanel.  I am sure there is more that must be wired and have had trouble finding a good article where the UpdatePanel, TimerControl, and GridView control are used together.  Examples that I have seen use Label controls and implement the OnTick event but it is not clear yet to me how to use this w/ a databound control like a GridView.  Can anyone suggest a link or 2 showing an example of this scenario. 

NOTE:  I am not currently programmatically "binding" the GridView control.  The GridView control and ObjectDataSource control are simply bound by setting the DataSourceID property of the GridView to the ID of the ObjectDataSource - they are bou

View Complete Post

More Related Resource Links

Accessing the different controls inside a GridView control

how we can access a particular control which resides inside a GridView control. In this article I will show you how you can access different controls inside a GridView control. We will see how we can access a TextBox control, a DropDownList control and a ListBox control. If you are working with ASP.NET 1.X then you might want to check out my article Accessing Different Controls Inside a DataGrid.

How to bind GridView and DropDownList controls using DataTable object

In .net framework 2.0, you can load a DataTable in memory by consuming a data source using a DataReader. In this version you will find the flexibility in accessing the DataReader means write access code once and use again and again using DataReader. To see the functionality of DataTable consider an example that is created using VS2005.

Gridview inside updatepanel


I am displaying large amount of data in gridview,the gridview placed within updatepanel,every 1sec i am refreshing updatepanel using ajax timer.my problem is while displaying large data the cpu performance is low,pls give idea to increase cpu performance..

Manually coding controls such as gridview, listview, repeater, etc.


using vs2010 and .net 4

In my project I have a separate DAL built from class files that I'd like to use to store my code for CRUD operations against my database.

I'm having a hard time finding examples of how to code server controls like the gridview, listview, repeater etc., for CRUD operations manually, i.e., without a datasource control of some flavor.

I don't have any problem manually coding the referenced controls to get my data, but I do have problems when it comes to coding them to perform CRUD operations unless I use a datasource control. When I use the datasource controls CRUD operations seem to automagically appear out of nowhere after they're configured.

Can someone point me to some samples somewhere? Have I missed a section at MSDN?


GridView editing without using data source controls?


I am binding my gridview without using a datasource control and instead doing it in the code behind. However, I would like to use the inline editing features of the gridview. Could someone please point me to an example that does gridview editing/updating 'manually' in the code behind?


how do i use javascript to change values of controls inside a gridview

i have 2 labels (lblRate,lblTotal) and a textbox (txtQuantity) in a itemtemplate of a gridview.I want to calculate the products of rate and quantity and show it in Total as the textbox loses focus...i cant use textchanged because i dont want the page to postback.How do i use javascript to achieve this??Please Help Urgently....<asp:TemplateField HeaderText="Rate">                <ItemTemplate>                    <asp:Label ID="lblRate" runat="server" Text='<%# Eval("Rate") %>' />                </ItemTemplate>            </asp:TemplateField> <asp:TemplateField HeaderText="Quantity">                <ItemTemplate>                    <asp:TextBox ID="txtQty" runat="server" />                </ItemTemplate>&

Validation Controls Inside UpdatePanel

Hi All,If you use validation control, the base validator will render script WebForm_OnSubmit() to the page and add form onsubmit "onsubmit="javascript:return WebForm_OnSubmit();". This script is used to fire client side validation event.Now I have a listview inside updatepanel, when click edit button to fire the listview edit mode, the above validation script is just not rendered. How shall I work around with that? I need to customize the client validation event here.Thanks.

how to apply validation controls on Gridview which is created dynamically

 hi, i created a gridview with two columns and 8 rows dynamically. All the rows are empty and editable at runtime. I am giving column names for this grid from some other .aspx page by passing column names using querystring.Because i am using this grid for three different pairs of column names.  i would like to know how to apply Required Field Validator, Regular Expression Validator  and Range Validator on Gridview textboxes. So that by using those validators i want to validate user inputs. And i would also like to know how to add rows at runtime for this grid. I am using ASP.net 2.0 and C#.net for this.(Visual Studio 2005) The code i am using to create gridview is below. <%@ Page Language="C#" AutoEventWireup="true" CodeFile="LoadData.aspx.cs" Inherits="LoadData" %>  <form id="form1" runat="server">  <div> <asp:GridView ID="GrdDynamic" runat="server" AutoGenerateColumns="False" ForeColor="#333333" BorderColor="GradientInactiveCaption" BorderStyle="Solid" style="z-index: 108; left: 24px; position: absolute; top: 13px">  <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />  <RowStyle BackColor="#EFF3FB"

When to call DataBind on GridView?

So I have a GridView and several events that can be triggered (such as filtering and inserting a new record) to manipulate the GridView.  I want to make sure that I'm not calling DataBind on Page_Load, especially since I might have to call it again when certain events fire.  Is there a way I can make it so I only have to call DataBind once on the GridView after Page_Load and anything else has fired?  Like some event that will absolutely fire last where I can put my DataBind?  The reason I need to do this is because the DataSource for the GridView is set programmatically from a DataView when the page is loaded, so DataBind needs to run every time.  Just, hopefully, not multiple times each time...

Databind on Gridview throwing System.InvalidCastException. Specific Cast Not Valid

Hello, I am working on a web app where when the user enters data into a text box and presses a filter radio button it should filter the Gridview on the page to the criteria entered.  I have done this before in previous applications with the same code listed below, but for some reason I am now getting the InvalidCastExeption error.  Any help would be appreciated, the source database is SQL and the data field is set to nvarchar and I am using a string to compare as you will see in the code.  I am just unsure why this worked in the past and is not working in this scenario. Thanks, Pete protected void filterLName_CheckedChanged(object sender, EventArgs e) { SHCDataContext existingCustomers = new SHCDataContext(); var filterExistingCustomers = existingCustomers.Customers.Where(c => c.custLastName.Contains(lNameTB.Text.ToString())); displayCustGV.DataSource = null; displayCustGV.DataSourceID = null; displayCustGV.DataSource = filterExistingCustomers; displayCustGV.DataBind(); }   Here is the stack trace....  Specified cast is not valid. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.I

Masterpage + UpdatePanel + Formview + EditItemTemplate = Null controls

I have a content page with a DropDownList in an UpdatePanel, a GridView in another UpdatePanel and a FormView in a 3rd UpdatePanel.  The databind's for the 3 controls happen in the code behind.  The FormView is populated when a row is clicked in the grid.  The Mode of the FormView is contolled by a series of buttons in that UpdatePanel, displayed as appropriate depending on the data in the grid row.  When the FormView is in Insert and the bound textboxes of that template are edited and (partial) posted back, I can retrieve the controls and their values with casts such as: if (Emp_Form.CurrentMode == FormViewMode.Insert) { CheckBox active = (CheckBox)Emp_Form.FindControl("cbActive"); ... But when the FormView is in Edit there aren't and controls during the (partial) post back.  A reference to them such as: if (Emp_Form.CurrentMode == FormViewMode.Edit) { TextBox usrNmTB = (TextBox)Emp_Form.FindControl("UserNmTbx"); sUsr = usrNmTB.Text.ToString(); ... results in a Null object reference exception.  When a button's onclick runat server event fires how should I capture the FormView's controls collection?  Why does it work for the Insert mode and not the Edit mode? Thanks in adva

Using FileUpload and GridView controls

Hi to all,I have four controls in my page: FileUpload, LinkButton, GridView, and Button.FileUpload - I use the control to browse and open an Excel file in the client machine.LinkButton - I use the control to trigger the method that copies the Excel file to the server, converts the data of Excel file to DataTable, deletes the Excel file, and returns the DataTable.GridView - I use the control to display the data.Button - I use the control to save the data to the database.I did not see any problem until I uploaded the third file that hanged my page. I noticed that every time I upload a file, the page become slower gradually.Each Excel file has 2,000 records, and every time the GridView displays an item, it searches the data on the database. I think, the more the data in the database, the slower the searches can be.To solve this problem, I set the AllowPaging property of GridView to true. The less displaying of items, the less searching of data can be. But, every time I change the page of GridView, I have to bind again the data to the GridView. In order to bind the data, FileUpload must contain the source file, but not because FileUpload frees the file when the page posts back. And I don't want the user browses the file every time he changes the page of GridView. That is very tedious.Does anyone have encountered this kind of problem? Please share us your solution.Your responses

Issue accessing textbox controls nested within a DetailsView within an UpdatePanel

I have a couple of textboxes nested with a detailsview, within an updatepanel.  When I try and access them from the code behind, it returns a null value as if they don't exist.  Can't figure out why that would be.ASPX code is: <asp:UpdatePanel ID="upSpecificShout" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="true" > <ContentTemplate> <asp:DetailsView ID="dvSingleShout" DataSourceID="sdsSingleShout" runat="server" AutoGenerateRows="false" OnDataBound="SetDVIcons" HeaderStyle-CssClass="noDisplay" > <EmptyDataTemplate> <p class="Watermark"> The panel on the left shows a list of everything you've shouted. (Your replies to other shouts are highlighted in blue/green.) </p> <p class="Watermark"> This right hand panel will show specific shouts with a list of replies etc.. Just do a little click on a shout title to display more detail here. </p> <p class="Watermark">

Gridview Dropdownlist Databind

Hi All, I am trying to Bind data dropdown list column only inside the gridview  while pageload using asp.net with c#.  I am able to bind the data to it but it is creating rows for total list itmes.  I want to bind to that at the first time i can able to see only one row. Later When i click on any one of the column then it will create a new row. Regards,

Textbox in headertemplate gridview lost text in updatepanel

Hi everybody,I never post on this forum because since I write code in asp.net I always solve issues by finding solutions with other members who have the problem before me. But this time I don't know how to do...This is my problem : I have a gridview inside an updatepanel and i modified some headers in order to filter the collection. This worked but when my updatepanel is updating, my textbox for the filter clear the value (the text) and lost focus.Is there any solution ?This is my code : <asp:UpdatePanel ID="UpdatePanelOrders" runat="server" UpdateMode="Conditional"> <Triggers> <asp:AsyncPostBackTrigger ControlID="btFilterClear" /> </Triggers> <ContentTemplate> <asp:GridView ID="OrdersView" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" ShowHeaderWhenEmpty="True" EnablePersistedSelection="True" PagerStyle-CssClass="pager" AlternatingRowStyle-CssClass="alter_row" SelectedRowStyle-CssClass="select_row" DataKeyNames="CustId,SalesOrders,CompCode,CustPO"> <Columns>

Problem with Dynamic Controls inside an UpdatePanel

Hello Everybody ,I have this problem,if anyone could help me i'll be so gratefull. I had been created some dynamic radio buttons in a loop inside a dinamy table which is inside an UpdatePanel , but i can not handle the events my code is below:public void MetodoCreacion(){RadioButton RBtn = null;Table table = new Table();TableRow row = null;TableCell cell = null;for (int i = 0; i < 5; i++){row = new TableRow();cell = new TableCell();RBtn = new RadioButton();RBtn.ID = "RBGN_" + i.ToString();RBtn.GroupName = "RBGN1";RBtn.Text = "Opcion " + i.ToString();RBtn.CheckedChanged += new EventHandler(RBtn_CheckedChanged);RBtn.AutoPostBack = true;cell.Controls.Add(RBtn);row.Controls.Add(cell);table.Controls.Add(row);}UpdatePanel1_UpdatePanelAnimationExtender.Controls .Add(table);}public void RBtn_CheckedChanged (object sender, EventArgs e){Label1.Text = ((RadioButton)sender).ID;}and the controls doesent call the event ...thanks a lot

controls disappear in UpdatePanel

Hello,         I have an update panel and inside the update panel I have a button. When I click that button I want to show textbox which is hidden (i.e. style="display:none"). I want to do it from client side. I wrote a javascript to show the textbox. But the textbox disappears after it is shown.   my button  code looks like this: <asp:ImageButton id="b1" OnClientClick="showTextBox();">.   showTextBox() code is called and it displays the textbox, but the click event goes to the server and comes back and when it comes back it doesnt know about the newly added textbox i guess. Is there an easy way to show the textbox from the client side without going to the server inside UpdatePanel.   Any help would be appreciated.   Thanks, Bharani
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