473,549 Members | 2,719 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Custom gridview with ajax updatepanel

1 New Member
Hi All,



I am implementing a custom gridview control, that emits some javascript to blink a row whenever a new row is added in gridview. The gridview is inside the <asp:updatepane l> for parital page rendering. The problem is when I put the gridview inside the updatepanel, I don't see the HTML table that is created as a result from rendering the gridviewcontrol and thus when new row is added, it does not blink, however when i just put the gridview without update panel, it the row blinks. How can I do that ?

custom gridview control code:
public class AlertWebControl : GridView

{

[Browsable(true)]

[Bindable(true)]

[Category("Appea rance")]

[DefaultValue("" )]

[Localizable(tru e)]

private string rowid;


protected override void RenderContents( HtmlTextWriter output)

{

base.RenderCont ents(output);

}

protected override void OnRowDataBound( GridViewRowEven tArgs e)

{

base.OnRowDataB ound(e);

if (e.Row.RowType == DataControlRowT ype.DataRow && e.Row.RowIndex == this.Rows.Count )

{

rowid = e.Row.ClientID;

}

}

protected override void OnDataBound(Eve ntArgs e)

{

base.OnDataBoun d(e);

if (this.Rows.Coun t > 1)

{


}

}

public override void UpdateRow(int rowIndex, bool causesValidatio n)

{

base.UpdateRow( rowIndex, causesValidatio n);

}



protected override void OnInit(EventArg s e)

{



base.OnInit(e);

string jscode = null;

string jskey = "jskey";

jscode = @"<script language='javas cript' type='text/javascript'>

var counter=1000;

var cellId=null;

var m_TheCurrentRow = null;

function BlinkRow( theRowObj )

{

m_TheCurrentRow = theRowObj;

window.setTimeo ut(ShowBaseColo r, 1000);

}

function ShowBaseColor()

{

document.getEle mentById(m_TheC urrentRow.id).s tyle.background Color='#C1DAD7' ;

document.getEle mentById(m_TheC urrentRow.id).s tyle.color='bla ck';

counter += 1000;

if(counter <= 10000)

{

window.setTimeo ut(ShowChangeCo lor, 1000);

}

}

function ShowChangeColor ()

{

document.getEle mentById(m_TheC urrentRow.id).s tyle.background Color='white';

document.getEle mentById(m_TheC urrentRow.id).s tyle.color='bla ck';

counter += 1000;

window.setTimeo ut(ShowBaseColo r, 1000)

}

</script>";

if (!Page.ClientSc ript.IsStartupS criptRegistered (jskey))

{

Page.ClientScri pt.RegisterStar tupScript(this. GetType(), jskey, jscode);

}

}

protected override void OnPreRender(Eve ntArgs e)

{

base.OnPreRende r(e);

if (this.Rows.Coun t > 0)

{

string rowkey = "rowkey";

string script = "<script language='javas cript'>";

script += "BlinkRow(docum ent.getElementB yId(\"" + rowid + "\"))";

script += "</script>";

Page.ClientScri pt.RegisterStar tupScript(this. GetType(), rowkey, script);

rowkey = null;

script = null;

}

}



}






Aspx page from where I am accessing the control inside updatepanel




<form runat="server" action="#">

<asp:ScriptMana ger ID="scrMgr" runat="server" EnablePartialRe ndering="true"/>

<asp:Timer ID="alerttmr" OnTick="GetAler ts" runat="server" Interval="10000 ">

</asp:Timer>

<asp:UpdatePane l ID="alertpanel " runat="server" UpdateMode="Con ditional" RenderMode="Blo ck">

<Triggers >

<asp:AsyncPostB ackTrigger ControlID="aler ttmr" />

</Triggers>


<ContentTemplat e>

<cc1:AlertWebCo ntrol ID="AlertWebCon trol1" runat="server" AutoGenerateCol umns="false">

<Columns>

<asp:BoundFie ld HeaderText="Ord er Id" DataField="Orde rId" />

<asp:BoundFie ld HeaderText="Lin e" DataField="Line " />

<asp:BoundFie ld HeaderText="Buy Sell" DataField="BuyS ell" />

<asp:BoundFie ld HeaderText="Qua ntity" DataField="Quan tity" />

<asp:BoundFie ld HeaderText="Sym bol" DataField="Symb ol" />

</Columns>

</cc1:AlertWebCon trol>

</ContentTemplate >

</asp:UpdatePanel >

</form>
Aug 21 '07 #1
1 3059
nateraaaa
663 Recognized Expert Contributor
The GridView cannot be used in an updated panel. A gridview requires a full post back and will not function properly using a partial page postback. Please see this site for additional details.

Nathan
Aug 21 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
2938
by: davidjgonzalez | last post by:
I have a GridView that has paging enabled. Each item (as defined in an ItemTemplate) includes several controls which have operations i would like to Atlas-enable. Everything is working well except when I page the GridView (the paging controllers are in the gridview's footer). The webpage doesnt scroll back to the top of the page, so when...
1
2695
by: mark4asp | last post by:
I moved a page to another web-site and now it's broke! I had 5 pages in their own web-site. These pages have now been moved to another web-site. Everything is fine except that one of the pages, which I had trouble with in the past (i.e. same problem), is now partly broke. The paging no longer fully works in the gridview. The...
0
3439
by: Reinhard | last post by:
Hi, Need some directions on Ajax, UpdatePanel and Gridview to achive the following: I like to show a Gridview with Data ONLY if the user is interested in Details, but without a full page reload! If the page loads, only a summary (eg. COUNT of recs) should be displayed
0
3158
by: jrnail23 | last post by:
I have a user control which contains an UpdatePanel, which contains a MultiView inside, with a GridView in one of the views. In my GridView, I have a ButtonField which is supposed to trigger a server-side operation, using the RowCommand functionality. In IE, this all works great, but in Firefox (v2.0.0.6), clicking the above mentioned...
1
5889
by: =?Utf-8?B?cmxt?= | last post by:
I have standard gridview in an updatePanel with an AJAX timer that refreshes the data every 5 seconds by calling the grids DataBind method in the tick event. This works great. However, I have a checkbox on the web page which when checked I want to hide some rows. The code that does the hiding is in the RowDataBound event where I do a bunch...
1
2435
by: Cirene | last post by:
I had a non-ajaxed page with a gridview. I wanted to ajax it. I added the scriptmanager at the top. I added an updatepanel below. I dragged the gridview into it. In my design view I got "error creating control - updatpanel1 - type 'system.web.ui.updatepanel' does not have an public property named 'gridview'.
4
5846
by: foolmelon | last post by:
Before AJAX, we were able to focus a cell in a gridview during a fullpage postback. After putting the gridview inside an UpdatePanel, we cannot focus a cell in this gridview anymore. Does anybody know if it is possible to make such focus? Thanks! Bill
13
3480
by: SAL | last post by:
Hello, I'm trying to include a popup in the ItemTemplate of a gridview row. The ItemTemplate for the field contains a textbox and when the user clicks in the textbox I want a popup panel to show allowing the user to make a selection from the popup window. I have enabled AJAX extensions and have a working sample outside of a gridview. However,...
8
6239
by: Nick | last post by:
Hi there, I have a GridView in an UpdatePanel, each time the UpdatePanels Load event fires I set the DataSource and call DataBind of the grid view. This works great once, I add an item to the list and the control updates, my breakpoints get in in the UpdatePanel Load event. Only problem is on the second time, even though the code is...
0
7520
marktang
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...
0
7450
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...
0
7720
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7957
jinu1996
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...
1
7470
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...
0
7809
tracyyun
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...
1
5368
isladogs
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...
0
3500
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3481
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.