1 Replies - 11795 Views - Last Post: 17 September 2014 - 03:03 PM Rate Topic: -----

#1 Gian7   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 39
  • Joined: 15-September 11

How to solve "Error executing child request for .aspx" problem

Posted 14 September 2014 - 07:19 PM

Hi! I'm new to asp.net and encountered an error when using Session[]
Why do I get "Error executing child request for profile.aspx" problem? In my other project, I didn't encounter that.

Because I'm trying to pass "ID" from shortlist.aspx to profile.aspx. That's why I used Session[]..

Shortlists.aspx.cs:
namespace prototype2
{
    public partial class shortlist : System.Web.UI.Page
    {
        string connString = @"Persist Security Info=False;Initial Catalog=prototype;Data Source=GIAN-PC\SQLEXPRESS; Integrated Security=false;User ID=sa;Password=gian123;";
        protected void Page_Load(object sender, EventArgs e)
        {
            loadgv();
        }

        protected void loadgv(){
            SqlConnection sqlConnection = new SqlConnection(connString);
            SqlCommand sqlCommand = new SqlCommand("select fname 'First Name', lname 'Last Name', role 'Role' from talents_profile", sqlConnection);
            sqlConnection.Open();
            SqlDataReader reader = sqlCommand.ExecuteReader();
            GridView1.DataSource = reader;
            GridView1.DataBind();
        }

        protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "viewprofile")
            {
                int index = Convert.ToInt32(e.CommandArgument);
                GridViewRow selectedRow = GridView1.Rows[index];
                TableCell viewprofile = selectedRow.Cells[0];
                String idx = viewprofile.ToString();
                Session["id"] = idx;
                Server.Transfer("profile.aspx");
            }
        }
    }
}



profile.aspx.cs:
namespace prototype2
{
    public partial class profile : System.Web.UI.Page
    {
        string connString = @"Persist Security Info=False;Initial Catalog=prototype;Data Source=GIAN-PC\SQLEXPRESS; Integrated Security=false;User ID=sa;Password=gian123;";
        protected void Page_Load(object sender, EventArgs e)
        {
            lblID.Text = Session["id"].ToString();
            loadgv();
        }

        protected void loadgv()
        {
            SqlConnection sqlConnection = new SqlConnection(connString);
            SqlCommand sqlCommand = new SqlCommand("select pic 'img url', fname 'First Name', lname 'Last Name', role 'Role' from talents_profile where talents_id = '"+ lblID.Text +"'", sqlConnection);
            sqlConnection.Open();
            SqlDataReader reader = sqlCommand.ExecuteReader();
            GridView1.DataSource = reader;
            GridView1.DataBind();
        }
    }
}



Is This A Good Question/Topic? 0
  • +

Replies To: How to solve "Error executing child request for .aspx" problem

#2 demausdauth   User is offline

  • D.I.C Addict
  • member icon

Reputation: 190
  • View blog
  • Posts: 692
  • Joined: 03-February 10

Re: How to solve "Error executing child request for .aspx" problem

Posted 17 September 2014 - 03:03 PM

Read up on Server.Transfer vs Response.Redirect.

a article
another article
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1