P
PeterKellner
I'm trying to create a gridview dynamically (in code from an
ObjectDataSource). When I create it in the aspx page and dynamically
add the datasource it works correctly. When I create it 100% in code
(no asp:GridView), the headers is created, the number of rows shown is
correct, but all the rows show empty without any controls.
What Am I missing?
Thanks
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
loadDynamicGridx();
}
//
private void loadDynamicGridx()
{
// if the new GridView() control is replaced with the
following in an
// aspx page, the grid gets poplulated as exptected. If the
gridview
// is created dynamically, the headers get set, the rows are
listed
// but they are all empty of controls or data.
// <asp:GridView ID="GrdDynamic" runat="server"
ShowHeader="true">
// </asp:GridView>
//
GridView GrdDynamic = new GridView();
ObjectDataSource ods = new
ObjectDataSource("MembershipUtilities.MembershipUserODS",
"GetMembers");
//Initialize the DataSource
GrdDynamic.DataSource = ods;
//Bind the datatable with the GridView.
GrdDynamic.DataBind();
}
Peter Kellner
http://peterkellner.net
ObjectDataSource). When I create it in the aspx page and dynamically
add the datasource it works correctly. When I create it 100% in code
(no asp:GridView), the headers is created, the number of rows shown is
correct, but all the rows show empty without any controls.
What Am I missing?
Thanks
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
loadDynamicGridx();
}
//
private void loadDynamicGridx()
{
// if the new GridView() control is replaced with the
following in an
// aspx page, the grid gets poplulated as exptected. If the
gridview
// is created dynamically, the headers get set, the rows are
listed
// but they are all empty of controls or data.
// <asp:GridView ID="GrdDynamic" runat="server"
ShowHeader="true">
// </asp:GridView>
//
GridView GrdDynamic = new GridView();
ObjectDataSource ods = new
ObjectDataSource("MembershipUtilities.MembershipUserODS",
"GetMembers");
//Initialize the DataSource
GrdDynamic.DataSource = ods;
//Bind the datatable with the GridView.
GrdDynamic.DataBind();
}
Peter Kellner
http://peterkellner.net