Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Maintaining my own DataSource

Status
Not open for further replies.

mbde

Programmer
Mar 14, 2005
55
US
I am in the midst of creating a re-usable composite control that just has a predefined grid on it, and a couple of text boxes to display customer information

I create a public datasource

public Customer DataSource
{
get{
object o = ViewState["DataSource"];
return (o == null)? null : (Customer)o;
}
set { ViewState["DataSource"]=value; }
}

and I override DataBind to do the custom mappings of the Cutomer object to each appropriate item

Customer is may up of various string variables and a List<Accounts> objects.

but when I put the statement
<cc:CustomerGrid Id="CustomerGrid" runat="server" DataSource='<% Eval("Customer") %>'>

The Databind runs before the assignment of the Datasoure, which I get because of the Eval statement.

I have looked into inheriting from DataboundControl. The one part that confuses me is the retrievedData parameter because my custom data does not adhere to IEnumerable.

Here is actual Code

Code:
<asp:CompleteGridView ID="AffiliationGrid" runat="server" 
    AutoGenerateColumns="False" SkinID="Common">
    <DetailTemplate>
        <cc:CustomerGrid ID="CustomerGrid1" runat="server" DataSource='<%# Eval("Customer") %>'/>
    </DetailTemplate>

So there is a list of Customer to an affiliation.

Thoughts on how to get the DataSource assigned before Databind Fires.
 
Figured it out

I was calling base.Databind on the control after trying to retreive the value by alling

base.DataBind();
CustomerGrid.DataSource = DataSource;
CustomerDatabind();

That worked.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top