473,394 Members | 1,766 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,394 software developers and data experts.

GridView inside update panel, fun ensues.

Hello,

I have a GridView that I put inside an update panel.
I have a control that attaches to the datasource of the gridview that filters the data, databinds the gridview and then updates the update panel that the gridview is in.

In my page render I put this so I could select a row by just clicking it.

Expand|Select|Wrap|Line Numbers
  1.     protected override void Render(HtmlTextWriter writer)
  2.     {
  3.         foreach (GridViewRow row in GridView1.Rows)
  4.         {
  5.             if (row.RowType == DataControlRowType.DataRow)
  6.             {
  7.                 row.Attributes.Add("onclick", Page.ClientScript.GetPostBackEventReference(GridView1, "Select$" + row.RowIndex.ToString(), true));
  8.             }
  9.         }
  10.         Page.ClientScript.RegisterForEventValidation(GridView1.UniqueID);
  11.         base.Render(writer);
  12.     }
  13.  
The row select works great on the first render of the page. However when I filter my gridview or just update the update panel my onclick attribute is not rendered in the ajax postback.

First hit of page
Expand|Select|Wrap|Line Numbers
  1. <tr onMouseOver="this.style.cursor='hand'; this.style.background='yellow';" onMouseOut="this.style.background='#FFFFFF';" onclick="__doPostBack('ctl00$ContentPlaceHolder1$CustomControl1$GridView1','Select$0')" style="color:#333333;background-color:White;"><td>mydata</td></tr>
  2.  
Capture of http ajax post using fiddler
Expand|Select|Wrap|Line Numbers
  1. <tr onMouseOver="this.style.cursor='hand'; this.style.background='yellow';" onMouseOut="this.style.background='#FFFFFF';" style="color:#333333;background-color:White;"><td>mydata</td></tr>
  2.  
Haaaalp! I'm not sure what is happening. The style attributes I put on in my rowdatabound event. The filter control I'm using does not seem to be the culprit because it is only touching my object datasource. So it must be something going on due my grid being in an update panel. Is there something about Update Panels that remove onclick or prevent the rendering in an ajax postback? I've stepped through and the attribute seems to be added in the Render... I'm at a complete loss. Any ideas???
Jun 18 '09 #1
4 11995
Ok, to solve this I put
Expand|Select|Wrap|Line Numbers
  1. e.Row.Attributes.Add("onclick", ((GridView)sender).Page.ClientScript.GetPostBackEventReference((GridView)sender, "Select$" + e.Row.RowIndex.ToString(), false)); 
  2.  
in my OnRowDataBound. I'm not sure why I didn't get the event validation error but whatever it works for now.
Jun 19 '09 #2
Frinavale
9,735 Expert Mod 8TB
I'm glad you solved your problem!
Thanks for sharing the solution :)

-Frinny
Jun 22 '09 #3
There is nothing in that website that is related to my question. Thanks for spamming my post dnanetwork.
Jun 27 '09 #4
Frinavale
9,735 Expert Mod 8TB
BiffMaGriff, I've deleted the post since it has no relevant help to your question.
Jun 29 '09 #5

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

Similar topics

0
by: de4ever | last post by:
I have used open/save dialog box inside update panel in asp.net.but it is not working because of the code line Response.WriteFile(path);.Can i use any thing else for opening a file through open/save...
2
by: durga2005 | last post by:
hi i have a textbox control that is validated using Regularexpression validator and these controls are placed inside update panel the validation does not work inside update panel
1
by: durga2005 | last post by:
hi I m validating a textbox using regular expression validator and these controls are placed inside the update panel the validation is not working inside update panel
0
by: durga2005 | last post by:
hi i just added one textbox and regular expression validator in the form and set the properties for regular expression validator control. then i placed these two controls inside update panel ....
1
by: durga2005 | last post by:
hi i have a textbox and regular expression validator control .i have placed these control inside update panel. just im validating the textbox with regular expression validator control when i...
0
by: hetalupadhyay | last post by:
hi i take one update panel nd put inside gridview when i click print button no operation perform and when i remove update panel then it work perfectly so wht i do?.................to solve this ...
0
by: AdonisL81 | last post by:
Hello, I am new to .NET I am having trouble with a asp update panel and Gridview. The Gridview control is inside the update panel and I am trying to have the gridview update from a form button....
6
by: majidkorai | last post by:
Hi All, I am working on an application where i have got, a content page within a Master Page. I have placed a gridview on the page. This gridview has three fields, one of them is TemplateFied, a...
2
by: Blacky | last post by:
Hi, I have a webform all the controls are in a update panel,i have to write a script for showing error messages in a popup. These are the scripts i tried 1.private void MessageBox(string...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
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,...
0
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...
0
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...

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.