none
linking of two ascx pages RRS feed

  • Question

  • HI

    Iam creating custom webpart on .Net.I want that when i deploy that webpart on sharepoint site then there is one search button,after click on that one grid view on different page should be open.

    For that I was adding webusercontrol(.ascx) for designing in project in .Net.I was creating 2 webusercontrols.one for search button and one for grid view.And run those pages in browser but there is some problem with datasource object and passing session for linking those pages

    using System;  
    using System.Data;  
    using System.Configuration;  
    using System.Collections;  
    using System.Web;  
    using System.Web.Security;  
    using System.Web.UI;  
    using System.Web.UI.WebControls;  
    using System.Web.UI.WebControls.WebParts;  
    using System.Web.UI.HtmlControls;  
    using System.Data.SqlClient;  
    using System.Diagnostics;  
     
    namespace Project1  
    {  
        public partial class WebUserControl2 : System.Web.UI.UserControl  
        {  
              
            protected void Page_Load(object sender, EventArgs e)  
            {  
               // Session["dataset"] = dsObject;  
     
            }  
     
     
     
            protected void Button1_Click1(object sender, EventArgs e)  
            {  
                  
              // GetDataSet(TextBox1.Text);  
              //  GridView1.DataSource = dsObject;  
                //GridView1.DataBind();  
                 
                Response.Redirect("WebForm1.aspx");  
              //  Session.Add("dataset", dsObject);  
            }  
     
        public DataSet GetDataSet()  
        {  
            string connectionString = default(string);  
            string selectSqlStatement = string.Format(@"select * from ResourceDetail WHERE EmpCode like '%{0}%'", TextBox1.Text);  
     
            SqlConnection connObject = null;  
            SqlCommand commObject = null;  
            SqlDataAdapter adapterObject = null;  
            DataSet dsObject = new DataSet();  
            //throw new Exception("The method or operation is not implemented.");  
            try  
            {  
                connectionString = ConfigurationManager.ConnectionStrings["ProjectManagementConnectionString"].ConnectionString;  
                connObject = new SqlConnection(connectionString);  
                commObject = new SqlCommand(selectSqlStatement, connObject);  
                adapterObject = new SqlDataAdapter(commObject);  
                adapterObject.Fill(dsObject);  
               Session.Add("dataset", dsObject);  
            }  
            catch (Exception exceptionObject)  
            {  
                EventLog.WriteEntry("Application", "Error :" + exceptionObject.Message, EventLogEntryType.Error);  
            }  
     
            return dsObject;  
            }  
        }  
    }  
    that code is for search button page.  
    Now there is code for grid view page  
    using System;  
    using System.Data;  
    using System.Configuration;  
    using System.Collections;  
    using System.Web;  
    using System.Web.Security;  
    using System.Web.UI;  
    using System.Web.UI.WebControls;  
    using System.Web.UI.WebControls.WebParts;  
    using System.Web.UI.HtmlControls;  
     
    namespace Project1  
    {  
        public partial class WebUserControl3 : System.Web.UI.UserControl  
        {  
            protected void Page_Load(object sender, EventArgs e)  
            {  
                 
                DataSet dsObject = new DataSet(Session["dataset"].ToString());  
                 
                GridView1.DataSource = dsObject;  
                GridView1.DataBind();  
                  
     
            }  
        }  
    check that code and tell me is there any problem with passing session aur some other problem with connection string



    reagrds
    pooja
    pooja ch
    Thursday, January 8, 2009 3:07 PM