Results 1 to 3 of 3

Thread: [RESOLVED] extedning user controls

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 2005
    Posts
    182

    Resolved [RESOLVED] extedning user controls

    I am very new to this c#. I was wondering if someone can help me in this problem... Say for example i have written the following control see code below..Now i want to add a paging (just an example) as another control, which however extend this control. How can i do that. I am trying to do it but it is giving me error. Can anyone correct me please.

    public partial class ThmbListing : System.Web.UI.UserControl
    {

    #region Fields ------------------------------------------------------------------------

    public DataSet ds ;
    public Icon icon;
    private int pagesize = 5;

    #endregion

    #region Public properties


    public int GridPageSize
    {
    get
    {
    return this.pagesize;
    }
    set
    {
    this.pagesize = value;
    this.GridView1.PageSize = value;

    }
    }


    #endregion

    #region Public Protected Methods

    public string setImagesNullValue(string imageValue)
    {
    string ImagesValues = "";

    if (imageValue != "")
    {
    ImagesValues = imageValue + "width=150&height=150";
    }
    else
    {
    ImagesValues = System.Configuration.ConfigurationManager.AppSettings["URL"] + "/images/imageNotAvailable.gif";
    }
    return ImagesValues;

    }

    protected void MyDataBind()
    {
    try
    {
    this.ds = new DataSet();
    this.icon = new Icon();
    SqlConnection cn = new SqlConnection();
    cn.ConnectionString = System.Configuration.ConfigurationManager.AppSettings["DBConnectionString"];
    SqlDataAdapter da = new SqlDataAdapter("select * from ResidentialListingView", cn);
    da.Fill(this.ds);
    this.GridView1.DataSource = this.ds;
    this.GridView1.DataBind();
    cn.Close();
    this.ds.Dispose();
    }
    catch { }



    }

    protected void Page_Load(object sender, EventArgs e)
    {
    if (!Page.IsPostBack)
    {
    //GridPageSize = 5;
    MyDataBind();

    }

    }

    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
    ViewState["CurrentPage"] = e.NewPageIndex;
    GridView1.PageIndex = e.NewPageIndex;
    MyDataBind();
    }

    protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
    {
    if (e.Row.RowType == DataControlRowType.Pager)
    {

    int count = GridView1.PageCount * GridView1.PageSize;
    int Totalpropery = this.ds.Tables[0].Rows.Count;
    int startRecrod = 0;
    int endRecrod = 0;

    startRecrod = (GridView1.PageIndex * GridView1.PageSize) + 1;
    if (GridView1.PageIndex + 1 == this.GridView1.PageCount)
    endRecrod = Totalpropery;
    else
    endRecrod = (GridView1.PageIndex + 1) * GridView1.PageSize;
    lblView.Text = "Viewing : <B>" + startRecrod + "</B> - <B>" + endRecrod + "</B> of <B>" + Totalpropery + "</B>";


    }

    }

    #endregion



    }

    /////Beolw is i am tryng to extend

    public partial class PageOrder :ThmbListing
    {

    protected void SizeList_SelectedIndexChanged(object sender, EventArgs e)
    {
    GridPageSize = Convert.ToInt32(SizeList.SelectedItem.Value);
    MyDataBind();
    }
    }

  2. #2
    Fanatic Member
    Join Date
    Jun 2004
    Location
    All useless places
    Posts
    917

    Re: extedning user controls

    What's the error description? I understand that while trying to compile with a partial class you need to have the other partial class in place as well (though I myself has never worked on it) but found this piece of info here.

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: extedning user controls

    Please don't post that you're getting an error and not give the error message or the location of the error. Also, please don't post code without [code] tags.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width