• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 892
  • Last Modified:

When i click on the link button present inside the gridview after it has been loaded i get stack overflow error

When i click on the linkbutton present inside the gridview, after it has been loaded, i get stack overflow error at line '0'.Is this the problem in the datatype overflow.

Can You tell me what may be the problem and where exactly i have to use stackoverflow exception.
0
Sukeshjph
Asked:
Sukeshjph
  • 4
  • 4
1 Solution
 
SteveH_UKCommented:
Stack overflow is caused by one of two things:

1)  Too many method calls.  This normally indicates that there is cyclic behaviour, for example method1 calls method2 which calls method3 which calls method1 which calls method2 which calls method3 ...

2)  Too much memory allocated on the stack.  This may be for structures, but in general this doesn't occur in .NET, but was common in C++ applications

I would put a breakpoint in your LinkButton_Click handler and see what it is doing.
0
 
gocemiCommented:

if you comment the code inside the link button ( comment all code inside the method) , rebuild and click again... do you get the error again?

if so, can you send the code that executes inside the link button clicked?

0
 
SukeshjphAuthor Commented:
My code in the onrowcommand is like this......

protected void gvFriendsUpdatedDetails_RowCommand(object sender, GridViewCommandEventArgs e)
    {
try
{

    {

        switch (e.CommandName)
        {
            case "Check":
                DateTime StartTime;
                DateTime EndTime;
                DateTime Span = System.DateTime.Today.Date.AddDays(-8);

                StartTime = Convert.ToDateTime(Span.AddDays(1).ToString().TrimEnd(("12:00:00 AM ").ToCharArray()));
                EndTime = Convert.ToDateTime(Span.AddDays(8).ToString().TrimEnd(("12:00:00 AM").ToCharArray()));
                int index = Convert.ToInt32(e.CommandArgument);
                Label lblMediaID = (Label)gvFriendsUpdatedDetails.Rows[index].FindControl("lblid");

                PersonId = Convert.ToInt64((lblMediaID.Text).ToString());
                ViewState["ClickedUserID"] = PersonId;


                LinkButton lnkProf = (LinkButton)gvFriendsUpdatedDetails.Rows[index].FindControl("lnkBtnProfessional");
                LinkButton lnkEdu = (LinkButton)gvFriendsUpdatedDetails.Rows[index].FindControl("lnkbtnEducational");
                LinkButton lnkPer = (LinkButton)gvFriendsUpdatedDetails.Rows[index].FindControl("lnkBtnPersonal");
                LinkButton lnkprofile = (LinkButton)gvFriendsUpdatedDetails.Rows[index].FindControl("lnkbtnProfile");
                Label lblMsg = (Label)gvFriendsUpdatedDetails.Rows[index].FindControl("lblMessage");



                serviceObject = new NetworkUpdateService();

                if (Convert.ToBoolean(ViewState["ForTodayOrOLd"]) == true)
                {

                    statusProfSingle = serviceObject.getProfessionalSingleStatus(PersonId, System.DateTime.Today);

                    statusEdu = serviceObject.getEducationalStatus(PersonId, System.DateTime.Today);
                    statusPersnl = serviceObject.getPersonalStatus(PersonId, System.DateTime.Today);
                    stausProfile = serviceObject.getProfileStatus(PersonId, System.DateTime.Today);
                    //ViewState["ForTodayOrOLd"] = false;
                }
                else
                {
                    statusProfSingle = serviceObject.getProfessionalSingleStatus(PersonId, StartTime, EndTime);
                    statusEdu = serviceObject.getEducationalStatus(PersonId, StartTime, EndTime);
                    statusPersnl = serviceObject.getPersonalStatus(PersonId, StartTime, EndTime);
                    stausProfile = serviceObject.getProfileStatus(PersonId, StartTime, EndTime);
                }


                if (!(statusProfSingle == false && statusEdu == false && statusPersnl == false && stausProfile == false))
                {
                    lblMsg.Visible = true;
                }

                if (statusProfSingle == true)
                    lnkProf.Visible = true;
                else
                    lnkProf.Visible = false;

                if (stausProfile == true)
                    lnkprofile.Visible = true;
                else
                    lnkprofile.Visible = false;

                if (statusEdu == true)
                    lnkEdu.Visible = true;
                else
                    lnkEdu.Visible = false;

                if (statusPersnl == true)
                {
                    lnkPer.Visible = true;
                }
                else
                {
                    lnkPer.Visible = false;
                }

                break;

            case "Professional":
                Response.Redirect("../Default.aspx?Id=" + ViewState["ClickedUserID"].ToString());

                break;
            case "Educational":
                Response.Redirect("../Default.aspx?Id=" + ViewState["ClickedUserID"].ToString());
                break;
            case "Personal":
                Response.Redirect("../Default.aspx?Id=" + ViewState["ClickedUserID"].ToString());
                break;
            case "Profile":
                Response.Redirect("../Default.aspx?Id=" + ViewState["ClickedUserID"].ToString());
                break;
       
    }

   



   
    #endregion
   

}


}
catch (StackOverflowException ex)
{


}


    }

I am working in c#.net...as u told i am doing a lot of method calls to determine whether to make some buttons visible or false....professional,personal,educational...buttons...but i think when i click on the firstname button i want to display these buttons according to their status.....but the time i get the data i also get stack oveflow error at line 0..but i am getting my result also....
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
SukeshjphAuthor Commented:
I am not gettin any stackoverflow exception in this code but still i am getting the error...
0
 
gocemiCommented:
I think that only place where you can get this exception is
if (Convert.ToBoolean(ViewState["ForTodayOrOLd"]) == true)
                {

                    statusProfSingle = serviceObject.getProfessionalSingleStatus(PersonId, System.DateTime.Today);

                    statusEdu = serviceObject.getEducationalStatus(PersonId, System.DateTime.Today);
                    statusPersnl = serviceObject.getPersonalStatus(PersonId, System.DateTime.Today);
                    stausProfile = serviceObject.getProfileStatus(PersonId, System.DateTime.Today);
                    //ViewState["ForTodayOrOLd"] = false;


serviceObject - is this your implementation?

can you identigy on which line this error is thrown?
0
 
SukeshjphAuthor Commented:
Serviceobject is another component or layer which again calls the required method of data accesslayer ...dataacess layer calls the stored procs and delivers the dataset to servicelayer and in turn servicelayer to user interface then... getprofstatus returns true or false based on that the linkbutton becomes visible=true or false...


I think there is no error....no exceptiion and data comes to gridview fine but the moment linkbuttons are visible another pop up comes "Stack overflow error at line 0".I don't know why this pop up is coming....
0
 
gocemiCommented:
this is error that is thrown on server and since you are using Ajax they are displayed in alert.

If you turn off Ajax and go trough standard post back you should see the error.

Also check the event logs (administrative tools->event viewer) there should be something written also.
0
 
SukeshjphAuthor Commented:
But i am not using ajax....is there any possibility of error what i think...

Personid which is a person's id i get it from a lable control .when passed to the servicelayer i get userid as a hexadecimal number like(0*4562400jt) rather than simple "1000" or ''1002".
 
I suspect here in this point i get some error...but even if i changed in to
PersonId = int.Parse((lblMediaID.Text).ToString());

previously it was like this
 PersonId = Convert.ToInt64((lblMediaID.Text).ToString());

i still get this error.
0
 
gocemiCommented:
if there is a problem with format of the number i think you should get number format exception or maybe out of range something...

But it seems that you are receiving javascript error

try this
http://www.webdeveloper.com/forum/archive/index.php/t-33308.html
or
http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_21591311.html
or
http://www.experts-exchange.com/Web/Web_Languages/JavaScript/Q_22007642.html

Probably you get javascript errors, can you check code that executes when you cliick on the button or when page is loaded?
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now