Data Binding within Data Bound Controls.

Data Binding within Data Bound Controls.

Post by Sril » Fri, 31 May 2002 17:18:56



Dear All,
Issue: Data Binding within Data Bound Controls.
Problem: I have a hashtable whose keys are Country Names
and each value is a collection of States in that country.
I need an external binding to the country name and an
internal binding of check boxes to the State collection of
that country. My display should look like this.

CountryA
StateA1  StateA2  StateA3

CountryB
StateB1  StateB2  StateB3  

I am new to .NET, but theoretically it seems possible.
Any ideas or code ??

Thanks
Sri

 
 
 

Data Binding within Data Bound Controls.

Post by John Viel » Sat, 01 Jun 2002 04:28:30


I haven't tried it, but my suggestion is that you make a DataSet from the
Hashtable.   Then just build a datagrid with an ItemTemplate that contains
your checkboxes.   Otherwise you will probably have to hook the
"DataBinding" event and do your own code.  After all, there's no inherent
way for built-in databinding to know about the data structure you are
storing in the HashTable.

--jv


Quote:> Dear All,
> Issue: Data Binding within Data Bound Controls.
> Problem: I have a hashtable whose keys are Country Names
> and each value is a collection of States in that country.
> I need an external binding to the country name and an
> internal binding of check boxes to the State collection of
> that country. My display should look like this.

> CountryA
> StateA1  StateA2  StateA3

> CountryB
> StateB1  StateB2  StateB3

> I am new to .NET, but theoretically it seems possible.
> Any ideas or code ??

> Thanks
> Sri


 
 
 

1. Data binding DropDownList user control within other user controls

I have a user control with a DataList object on it.  Within the
<EditItemTemplate> I have a user control that is a special DropDownList
object.

<asp:DataList ID="usercontrol1" Runat="Server"
    OnEditCommand="dlEdit_Command"
    OnUpdateCommand="dlUpdate_Command"
    OnDeleteCommand="dlDelete_Command"
    OnCancelCommand="dlCancel_Command">

<ItemTemplate>
    <asp:Button ID="btnEdit" Runat="server" Text="Edit" CommandName="Edit"
CommandArgument='<%# Container.DataItem("ID") %>' />
    <asp:Label ID="lblItem" Runat="server" Text='<%#
Container.DataItem("Line") %>' />
</ItemTemplate>
<EditItemTemplate>
    <mytag:MyDropDownList ID="ddlDropDownList" Runat="server"
SelectedValue='<%# Container.DataItem("Value") %>' />
</EditItemTemplate>
</asp:DataList>

My MyDropDownList component on page load calls a method that takes the
SelectedValue and sets the SelectedIndex of the DropDownList object in
MyDropDownList object.  When I do this I receive "Object reference not set
to an instance of an object" errors.  I've run tests and have found that the
SelectedValue property doesn't have a value either.  It acts like the object
doesn't exist yet.

What do I have to do?  What is the firing order of methods when I perform a
databind on the datalist?
Am I at least close?

Thanks, Keith Geringer

2. 1990 TURING COLLOQUIUM

3. Extracting Data Binding expression from control and bind it.

4. HTTPS Post

5. Data binding control properties with custom binding expression

6. A moment of silence for Apple Computer, now controlled by M$

7. How to set data binding of treeView control to access data?

8. CD Slide show info needed

9. Binding Image Control In a Data List to an SQL Image data type

10. data binding of the html controls with data island in ASP.NET

11. Binding bug when bound to a complex data member

12. Inserting new Data into Bound Datagrid + Bound Textboxes (Master/Detail) in WinForm

13. !! Help Binding A StoredProcedure record result to the Data Set and bind it to DataGrid