I have got the row index of the gridview on which we have made the mouse over.what i am looking is that how to get the values of each cells in that row inside the javascript
Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback
or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.
The Invalid postback or callback argument error occurs when the layout of the form being submitted differs from what has been defined on the server side and event validation is enabled It is a feature to stop people from submitting their own forms to an
ASP.NET page.
This is usually caused by adding new fields or items to a form tag using client-side script.
This error can be eliminated by setting the EnableEventValidation flag.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" EnableEventValidation="false" %>
or with a setting in the web.config file:
<pages enableEventValidation="true"/>
var index = "--your index value--"; // where are you getting the index value from? server side? or client side? please keep in mind that in the client side, it will assume header as the first row, so if you get it from the server side, add 1 to start the
index value.
var grid = document.getElementById('<%= GridView1.ClientID %>');
for(var i=0; i < grid.rows[index].cells.length; i++)
{
alert(grid.rows[index].cells[i].innerHTML); // this will display value in each cell of that row
}
Hope it helps. Mark as Answer if it does.
KAMMIE Don't forget to Mark as Answer on the post that helped you. It encourages them to share their knowledge, and it helps others to easily identify the solution.
Marked as answer by jacobodolil on Mar 25, 2009 02:24 PM
var index = "--your index value--"; // where are you getting the index value from? server side? or client side? please keep in mind that in the client side, it will assume header as the first row, so if you get it from the server side, add 1 to start the
index value.
var grid = document.getElementById('<%= GridView1.ClientID %>');
for(var i=0; i < grid.rows[index].cells.length; i++)
{
alert(grid.rows[index].cells[i].innerHTML); // this will display value in each cell of that row
}
Hope it helps. Mark as Answer if it does.
KAMMIE Don't forget to Mark as Answer on the post that helped you. It encourages them to share their knowledge, and it helps others to easily identify the solution.
var index = "--your index value--"; // where are you getting the index value from? server side? or client side? please keep in mind that in the client side, it will assume header as the first row, so if you get it from the server side, add 1 to start the
index value.
var grid = document.getElementById('<%= GridView1.ClientID %>');
for(var i=0; i < grid.rows[index].cells.length; i++)
{
alert(grid.rows[index].cells[i].innerHTML); // this will display value in each cell of that row
}
Hope it helps. Mark as Answer if it does.
I think that he is getting the error because he is adding controls to the Grid from the client-side. This invalidates the original rendering of the page. You get the same error if you add options to a DropDownListBox and cause it to do a PostBack. If you
have a need to do that, you need to turn event validation off. There's no way around it.
jacobodolil
Participant
868 Points
228 Posts
how to get Gridview Cell values inside the javascript
Mar 25, 2009 01:11 PM|LINK
Hi
I have got the row index of the gridview on which we have made the mouse over.what i am looking is that how to get the values of each cells in that row inside the javascript
Help me please
document.getElementById.rows[rwindex].cells[clindex].innerTEXT;
doesnt work for me
Jacob
Mark As Answer if this post Helped you
qwe123kids
All-Star
48619 Points
7957 Posts
MVP
Re: how to get Gridview Cell values inside the javascript
Mar 25, 2009 01:22 PM|LINK
Hi,
Check the Follwing links
http://www.codeproject.com/KB/webforms/JavaRowSelect.aspx
http://www.codegod.de/webappcodegod/GridView-Javascript-Click-Row-and-Ajax-AID302.aspx
http://msmvps.com/blogs/SimpleMan/archive/2005/07/14/57323.aspx
Hope It helps
Avinash Tiwari
Remember to click “Mark as Answer” on the post, if it helps you.
jacobodolil
Participant
868 Points
228 Posts
Re: how to get Gridview Cell values inside the javascript
Mar 25, 2009 01:50 PM|LINK
i have used this code to do the postbackc.Attributes[
"onclick"] = ClientScript.GetPostBackClientHyperlink(
this.grd1, "Select$" + e.Row.RowIndex);but am getting an error
Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.
Jacob
Mark As Answer if this post Helped you
NC01
All-Star
82577 Points
15430 Posts
MVP
Re: how to get Gridview Cell values inside the javascript
Mar 25, 2009 02:10 PM|LINK
The Invalid postback or callback argument error occurs when the layout of the form being submitted differs from what has been defined on the server side and event validation is enabled It is a feature to stop people from submitting their own forms to an ASP.NET page.
This is usually caused by adding new fields or items to a form tag using client-side script.
This error can be eliminated by setting the EnableEventValidation flag.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" EnableEventValidation="false" %>
or with a setting in the web.config file:
<pages enableEventValidation="true"/>
For more information see:
http://www.google.com/search?hl=en&q=System.ArgumentException%3A+Invalid+postback+or+callback+argument&btnG=Google+Search&aq=f&oq=
NC...
kammie
Contributor
2163 Points
352 Posts
Re: how to get Gridview Cell values inside the javascript
Mar 25, 2009 02:13 PM|LINK
Try this.....
var index = "--your index value--"; // where are you getting the index value from? server side? or client side? please keep in mind that in the client side, it will assume header as the first row, so if you get it from the server side, add 1 to start the index value.
var grid = document.getElementById('<%= GridView1.ClientID %>');
for(var i=0; i < grid.rows[index].cells.length; i++)
{
alert(grid.rows[index].cells[i].innerHTML); // this will display value in each cell of that row
}
Hope it helps. Mark as Answer if it does.
Don't forget to Mark as Answer on the post that helped you. It encourages them to share their knowledge, and it helps others to easily identify the solution.
kammie
Contributor
2163 Points
352 Posts
Re: how to get Gridview Cell values inside the javascript
Mar 25, 2009 02:15 PM|LINK
Try this.....
var index = "--your index value--"; // where are you getting the index value from? server side? or client side? please keep in mind that in the client side, it will assume header as the first row, so if you get it from the server side, add 1 to start the index value.
var grid = document.getElementById('<%= GridView1.ClientID %>');
for(var i=0; i < grid.rows[index].cells.length; i++)
{
alert(grid.rows[index].cells[i].innerHTML); // this will display value in each cell of that row
}
Hope it helps. Mark as Answer if it does.
Don't forget to Mark as Answer on the post that helped you. It encourages them to share their knowledge, and it helps others to easily identify the solution.
NC01
All-Star
82577 Points
15430 Posts
MVP
Re: how to get Gridview Cell values inside the javascript
Mar 25, 2009 02:49 PM|LINK
I think that he is getting the error because he is adding controls to the Grid from the client-side. This invalidates the original rendering of the page. You get the same error if you add options to a DropDownListBox and cause it to do a PostBack. If you have a need to do that, you need to turn event validation off. There's no way around it.
NC...