|
-
Aug 28th, 2006, 12:22 AM
#1
Thread Starter
Addicted Member
[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();
}
}
-
Sep 5th, 2006, 08:59 AM
#2
Fanatic Member
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.
-
Sep 5th, 2006, 06:29 PM
#3
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|