DropDownList in DataGrid ColumTemplate Problem

  • Thread starter Thread starter Christian
  • Start date Start date
C

Christian

Hi,

I have a datagrid on an ASP.NET page, which has a custom columntemplate. In
this columntemplate I
would like to have a DropDownList, which is shown, when the user edits the
record. However,
I can't manage to bind the DropDownListField to the underlaying dataset, so
it shows
the contents of the underlying database field.

Here is the relevant ASP Code:

<EditItemTemplate>
<asp:DropDownList id=dlMediaType runat="server" DataSource='<%#
DataBinder.Eval(Container, "DataItem.type") %>' Width="168px" Text='<%#
DataBinder.Eval(Container, "DataItem.type") %>'>
</asp:DropDownList>
</EditItemTemplate>

The field from the underlaying table is called "Type".

What I get with this code is, that the DropDownList displays a single
character of the contents of
the "type" field in each line of the DropDownList; e.g. if the type field is
"DVD (TV)", the
DropDownList contains

D
V
D

(
T
V
)

what's wrong here ? Thanx,
Christian
 
Why do you have the datasource and text binded to the same field?

Shouldn't the datasource be a list of some kind and the text would bind to
each entity in the list?
 
Shouldn't the datasource be a list of some kind and the text would bind to
each entity in the list?

Oooops ... yes ... now it works. Partially. What I still don't get is the
difference
between actually binding the DropDownList to the database field and binding
it to a second datasource that actually provides the items within the list
.... :(
 
Back
Top