473,326 Members | 2,126 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Custom gridview with ajax updatepanel

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:updatepanel> 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("Appearance")]

[DefaultValue("")]

[Localizable(true)]

private string rowid;


protected override void RenderContents(HtmlTextWriter output)

{

base.RenderContents(output);

}

protected override void OnRowDataBound(GridViewRowEventArgs e)

{

base.OnRowDataBound(e);

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

{

rowid = e.Row.ClientID;

}

}

protected override void OnDataBound(EventArgs e)

{

base.OnDataBound(e);

if (this.Rows.Count > 1)

{


}

}

public override void UpdateRow(int rowIndex, bool causesValidation)

{

base.UpdateRow(rowIndex, causesValidation);

}



protected override void OnInit(EventArgs e)

{



base.OnInit(e);

string jscode = null;

string jskey = "jskey";

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

var counter=1000;

var cellId=null;

var m_TheCurrentRow = null;

function BlinkRow( theRowObj )

{

m_TheCurrentRow = theRowObj;

window.setTimeout(ShowBaseColor, 1000);

}

function ShowBaseColor()

{

document.getElementById(m_TheCurrentRow.id).style. backgroundColor='#C1DAD7';

document.getElementById(m_TheCurrentRow.id).style. color='black';

counter += 1000;

if(counter <= 10000)

{

window.setTimeout(ShowChangeColor, 1000);

}

}

function ShowChangeColor()

{

document.getElementById(m_TheCurrentRow.id).style. backgroundColor='white';

document.getElementById(m_TheCurrentRow.id).style. color='black';

counter += 1000;

window.setTimeout(ShowBaseColor, 1000)

}

</script>";

if (!Page.ClientScript.IsStartupScriptRegistered(jske y))

{

Page.ClientScript.RegisterStartupScript(this.GetTy pe(), jskey, jscode);

}

}

protected override void OnPreRender(EventArgs e)

{

base.OnPreRender(e);

if (this.Rows.Count > 0)

{

string rowkey = "rowkey";

string script = "<script language='javascript'>";

script += "BlinkRow(document.getElementById(\"" + rowid + "\"))";

script += "</script>";

Page.ClientScript.RegisterStartupScript(this.GetTy pe(), rowkey, script);

rowkey = null;

script = null;

}

}



}






Aspx page from where I am accessing the control inside updatepanel




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

<asp:ScriptManager ID="scrMgr" runat="server" EnablePartialRendering="true"/>

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

</asp:Timer>

<asp:UpdatePanel ID="alertpanel" runat="server" UpdateMode="Conditional" RenderMode="Block">

<Triggers >

<asp:AsyncPostBackTrigger ControlID="alerttmr" />

</Triggers>


<ContentTemplate>

<cc1:AlertWebControl ID="AlertWebControl1" runat="server" AutoGenerateColumns="false">

<Columns>

<asp:BoundField HeaderText="Order Id" DataField="OrderId" />

<asp:BoundField HeaderText="Line" DataField="Line" />

<asp:BoundField HeaderText="BuySell" DataField="BuySell" />

<asp:BoundField HeaderText="Quantity" DataField="Quantity" />

<asp:BoundField HeaderText="Symbol" DataField="Symbol" />

</Columns>

</cc1:AlertWebControl>

</ContentTemplate>

</asp:UpdatePanel>

</form>
Aug 21 '07 #1
1 3044
nateraaaa
663 Expert 512MB
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
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...
1
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,...
0
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...
0
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...
1
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...
1
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...
4
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...
13
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...
8
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...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.