javascript __dopostback System.NullReferenceException
-
Here's the problem : When the gvWorkReportList is invisble and gvWorkReportList.FooterRow =null in page loading i get the bellow error :
Quote:
System.NullReferenceException: Object reference not set to an instance of an object. the error is on this part of code : __doPostBack('<%=gvWorkReportList.FooterRow.FindControl("lnkAdd").UniqueID%>', '');
Quote:
this is the piece of my code!
<script type="text/javascript">
function KeyDownHandler() { // process only the Enter key if (event.keyCode == 13) { \_\_doPostBack('<%=gvWorkReportList.FooterRow.FindControl("lnkAdd").UniqueID%>', ''); } } </script>
This doesn't seem like it should be that hard, so if someone could just give me a kick in the right direction, that'd be awesome. I have used these solution but it dosen't work :
var grid = document.getElementById('<%=gvWorkReportList.FooterRow.FindControl("lnkAdd").UniqueID%>');
if (grid != null) {
__doPostBack('<%=gvWorkReportList.FooterRow.FindControl("lnkAdd").UniqueID%>', '');}
var grid = document.getElementById("ctl00_ContentPlaceHolderContent_gvWorkReportList");
if (grid != null) {
__doPostBack('<%=gvWorkReportList.FooterRow.FindControl("lnkAdd").UniqueID%>', '');}
var gridFooter = gvWorkReportList.FooterRow;
if (gridFooter != null) {
__doPostBack('<%=gvWorkReportList.FooterRow.FindControl("lnkAdd").UniqueID%>', '');}
-
Here's the problem : When the gvWorkReportList is invisble and gvWorkReportList.FooterRow =null in page loading i get the bellow error :
Quote:
System.NullReferenceException: Object reference not set to an instance of an object. the error is on this part of code : __doPostBack('<%=gvWorkReportList.FooterRow.FindControl("lnkAdd").UniqueID%>', '');
Quote:
this is the piece of my code!
<script type="text/javascript">
function KeyDownHandler() { // process only the Enter key if (event.keyCode == 13) { \_\_doPostBack('<%=gvWorkReportList.FooterRow.FindControl("lnkAdd").UniqueID%>', ''); } } </script>
This doesn't seem like it should be that hard, so if someone could just give me a kick in the right direction, that'd be awesome. I have used these solution but it dosen't work :
var grid = document.getElementById('<%=gvWorkReportList.FooterRow.FindControl("lnkAdd").UniqueID%>');
if (grid != null) {
__doPostBack('<%=gvWorkReportList.FooterRow.FindControl("lnkAdd").UniqueID%>', '');}
var grid = document.getElementById("ctl00_ContentPlaceHolderContent_gvWorkReportList");
if (grid != null) {
__doPostBack('<%=gvWorkReportList.FooterRow.FindControl("lnkAdd").UniqueID%>', '');}
var gridFooter = gvWorkReportList.FooterRow;
if (gridFooter != null) {
__doPostBack('<%=gvWorkReportList.FooterRow.FindControl("lnkAdd").UniqueID%>', '');}
Hi, if the gridview is invisible i.e. you have made
visible = "false"
, the control will not be rendered into the client, and object will go null. So, this is what happening in your case. if you want the gridview to be rendered into the client but not to be displayed, then try by usingstyle
attribute like this.style = "display: none;"
. if you do so, probably you can accessUniqueID
. hope it helps.Vande Matharam - Jai Hind
-
Hi, if the gridview is invisible i.e. you have made
visible = "false"
, the control will not be rendered into the client, and object will go null. So, this is what happening in your case. if you want the gridview to be rendered into the client but not to be displayed, then try by usingstyle
attribute like this.style = "display: none;"
. if you do so, probably you can accessUniqueID
. hope it helps.Vande Matharam - Jai Hind
thanks for solution. But i dont need to get access when it is invisible. How i can control it if gridview in invisible the the code
__doPostBack('<%=gvWorkReportList.FooterRow.FindControl("lnkAdd").UniqueID%>', '');
doesnt run. Thanks in advanced!
-
thanks for solution. But i dont need to get access when it is invisible. How i can control it if gridview in invisible the the code
__doPostBack('<%=gvWorkReportList.FooterRow.FindControl("lnkAdd").UniqueID%>', '');
doesnt run. Thanks in advanced!
Hi, try like below.
var grid = document.getElementById('<%=gvWorkReportList.ClientID%>');
if (grid != null) {
__doPostBack('<%=gvWorkReportList.FooterRow.FindControl("lnkAdd").UniqueID%>', '');
}hope it works.
Vande Matharam - Jai Hind
-
Hi, try like below.
var grid = document.getElementById('<%=gvWorkReportList.ClientID%>');
if (grid != null) {
__doPostBack('<%=gvWorkReportList.FooterRow.FindControl("lnkAdd").UniqueID%>', '');
}hope it works.
Vande Matharam - Jai Hind
not used! Cause :
var grid = document.getElementById('<%=gvWorkReportList.ClientID%>');
is not null . but this code :
gvWorkReportList.FooterRow
is null. Thnaks in advanced!
-
Here's the problem : When the gvWorkReportList is invisble and gvWorkReportList.FooterRow =null in page loading i get the bellow error :
Quote:
System.NullReferenceException: Object reference not set to an instance of an object. the error is on this part of code : __doPostBack('<%=gvWorkReportList.FooterRow.FindControl("lnkAdd").UniqueID%>', '');
Quote:
this is the piece of my code!
<script type="text/javascript">
function KeyDownHandler() { // process only the Enter key if (event.keyCode == 13) { \_\_doPostBack('<%=gvWorkReportList.FooterRow.FindControl("lnkAdd").UniqueID%>', ''); } } </script>
This doesn't seem like it should be that hard, so if someone could just give me a kick in the right direction, that'd be awesome. I have used these solution but it dosen't work :
var grid = document.getElementById('<%=gvWorkReportList.FooterRow.FindControl("lnkAdd").UniqueID%>');
if (grid != null) {
__doPostBack('<%=gvWorkReportList.FooterRow.FindControl("lnkAdd").UniqueID%>', '');}
var grid = document.getElementById("ctl00_ContentPlaceHolderContent_gvWorkReportList");
if (grid != null) {
__doPostBack('<%=gvWorkReportList.FooterRow.FindControl("lnkAdd").UniqueID%>', '');}
var gridFooter = gvWorkReportList.FooterRow;
if (gridFooter != null) {
__doPostBack('<%=gvWorkReportList.FooterRow.FindControl("lnkAdd").UniqueID%>', '');}
Quote:
**_This doesn't seem like it should be that hard, so if someone could just give me a kick in the right direction, that'd be awesome._**