EugeneC
asked on
Populate detailsview from gridview via generic list
I am populating a gridview from a generic list as follows
ProgrammeCollection programList = new ProgrammeCollection();
//the "PopulateAllUsersFromDatab ase" method calls the
//"UserDataHelper.Populate DataList" method that returns a generic collection (UserCollection) of user objects
programList.PopulateAllPro grammesFro mDatabase( );
//bind the grid
UserGridView.DataSource = programList;
UserGridView.DataBind();
I need to be able to use the detailsview control with the grid. For example, if
you select a column in the datagrid then the detailsview is populated with the
record, eventually I want to be able to edit details in the view.
Regards
ProgrammeCollection programList = new ProgrammeCollection();
//the "PopulateAllUsersFromDatab
//"UserDataHelper.Populate
programList.PopulateAllPro
//bind the grid
UserGridView.DataSource = programList;
UserGridView.DataBind();
I need to be able to use the detailsview control with the grid. For example, if
you select a column in the datagrid then the detailsview is populated with the
record, eventually I want to be able to edit details in the view.
Regards
ASKER
Hi Bob
No I have not - I have not used them before.
No I have not - I have not used them before.
If you are binding to a GridView, then binding to a DetailsView is very similar. You would need to define the Fields that would bind to the properties for the bound object.
Bob
Bob
ASKER
Do you have an example Bob?
Example:
<asp:DetailsView ID="DetailsView1" runat="server" Height="50px" Style="z-index: 100;
left: 60px; position: absolute; top: 36px" Width="125px" AutoGenerateRows="False">
<Fields>
<asp:BoundField DataField="Name" />
<asp:BoundField DataField="Address" />
</Fields>
</asp:DetailsView>
public class Person
{
private string _name = "";
private string _address = "";
public string Name
{
get { return _name; }
set { _name = value; }
}
public string Address
{
get { return _address; }
set { _address = value; }
}
}
Bob
<asp:DetailsView ID="DetailsView1" runat="server" Height="50px" Style="z-index: 100;
left: 60px; position: absolute; top: 36px" Width="125px" AutoGenerateRows="False">
<Fields>
<asp:BoundField DataField="Name" />
<asp:BoundField DataField="Address" />
</Fields>
</asp:DetailsView>
public class Person
{
private string _name = "";
private string _address = "";
public string Name
{
get { return _name; }
set { _name = value; }
}
public string Address
{
get { return _address; }
set { _address = value; }
}
}
Bob
ASKER
Thanks
Is there a way to do it totally in code behind c#?
Is there a way to do it totally in code behind c#?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Bob