nabeelalkaff
Programmer
Hi,
I made a UserControl which is simply contains a GridView which reads its data from a database using SqlDataSource.
I read many articles on the subject already but I couldn't solve my problem.My problem is when I add my WebPart in SharePoint 2007 it is working but show nothing.I think it is working because I fixed some errors about reading from the database but after fixing all the errors I see nothing?
The WebPart code is as following:
using System;
using System.Runtime.InteropServices;
using System.Web.UI;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Serialization;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.WebPartPages;
namespace TrashMethodsWebPart
{
[Guid("c6a51b7a-a1f1-4637-ac65-040842397b7a")]
public class TrashMethodsWebPart : System.Web.UI.WebControls.WebParts.WebPart
{
UserControl userControl;
System.Web.UI.WebControls.GridView gvwStore;
public TrashMethodsWebPart()
{
this.ExportMode = WebPartExportMode.All;
}
protected override void CreateChildControls()
{
base.CreateChildControls();
// TODO: add custom rendering code here.
this.Controls.Clear();
userControl = (UserControl)this.Page.LoadControl(@"/_controltemplates/TrashUserControl.ascx");
userControl.ID = "us1";
gvwStore = (System.Web.UI.WebControls.GridView)userControl.FindControl("gvwStore");
gvwStore.PageIndexChanging += new System.Web.UI.WebControls.GridViewPageEventHandler(gvwStore_PageIndexChanging);
gvwStore.DataBind();
this.EnsureChildControls();
this.Controls.Add(userControl);
}
void gvwStore_PageIndexChanging(object sender, System.Web.UI.WebControls.GridViewPageEventArgs e)
{
gvwStore.PageIndex = e.NewPageIndex;
throw new Exception("The method or operation is not implemented.");
}
protected override void RenderContents(HtmlTextWriter writer)
{
//base.RenderContents(writer);
UserControl us1 = (UserControl)this.FindControl("us1");
us1.RenderControl(writer);
}
protected override void Render(HtmlTextWriter writer)
{
// TODO: add custom rendering code here.
// writer.Write("Output HTML");
}
}
}
I made a UserControl which is simply contains a GridView which reads its data from a database using SqlDataSource.
I read many articles on the subject already but I couldn't solve my problem.My problem is when I add my WebPart in SharePoint 2007 it is working but show nothing.I think it is working because I fixed some errors about reading from the database but after fixing all the errors I see nothing?
The WebPart code is as following:
using System;
using System.Runtime.InteropServices;
using System.Web.UI;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Serialization;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.WebPartPages;
namespace TrashMethodsWebPart
{
[Guid("c6a51b7a-a1f1-4637-ac65-040842397b7a")]
public class TrashMethodsWebPart : System.Web.UI.WebControls.WebParts.WebPart
{
UserControl userControl;
System.Web.UI.WebControls.GridView gvwStore;
public TrashMethodsWebPart()
{
this.ExportMode = WebPartExportMode.All;
}
protected override void CreateChildControls()
{
base.CreateChildControls();
// TODO: add custom rendering code here.
this.Controls.Clear();
userControl = (UserControl)this.Page.LoadControl(@"/_controltemplates/TrashUserControl.ascx");
userControl.ID = "us1";
gvwStore = (System.Web.UI.WebControls.GridView)userControl.FindControl("gvwStore");
gvwStore.PageIndexChanging += new System.Web.UI.WebControls.GridViewPageEventHandler(gvwStore_PageIndexChanging);
gvwStore.DataBind();
this.EnsureChildControls();
this.Controls.Add(userControl);
}
void gvwStore_PageIndexChanging(object sender, System.Web.UI.WebControls.GridViewPageEventArgs e)
{
gvwStore.PageIndex = e.NewPageIndex;
throw new Exception("The method or operation is not implemented.");
}
protected override void RenderContents(HtmlTextWriter writer)
{
//base.RenderContents(writer);
UserControl us1 = (UserControl)this.FindControl("us1");
us1.RenderControl(writer);
}
protected override void Render(HtmlTextWriter writer)
{
// TODO: add custom rendering code here.
// writer.Write("Output HTML");
}
}
}