* Bill Gower wrote, On 31-7-2007 1:17:
> Do you mean in the Page Load event?
No. Open the page with the dropdown in the designer. Look in the
properties. There's an items property. Open the items property with the
little [...] buton and click the add button. Give the thing a valeu of
-1 and clear the text that's automatically put in there. Close the
window and look for the AppendDataboundItems and set it to true.
Now if you load the page, it has an empty item on top. There's no need
to set it to the empty value, because the dropdown will always default
to it's top-most item unless specified otherwise.
Jesse
>> * Bill Gower wrote, On 31-7-2007 0:06:
>>> I have a asp.net page that has a DDL tied to a ObjectDataSource. I want
[quoted text clipped - 17 lines]
>>
>> Jesse
Brandon Gano - 31 Jul 2007 02:12 GMT
If you can't use the designer (either because you are using nested master
pages or because you just can't stomach the output), you can do it in the
aspx as follows:
<asp:SqlDataSource ID="MyDataSource" ... />
<asp:DropDownList DataSourceID="MyDataSource" AppendDataBoundItems="true">
<asp:ListItem Value="" Text="" />
</asp:DropDownList>
>* Bill Gower wrote, On 31-7-2007 1:17:
>> Do you mean in the Page Load event?
[quoted text clipped - 32 lines]
>>>
>>> Jesse
Bill Gower - 31 Jul 2007 03:51 GMT
Thanks that really helped. Just one problem to solve, even though I have
deleted the Text value in the Items collection field, it still displays -1
in the drop down and I did check, I am displaying the proper field in the
list.
Bill
>* Bill Gower wrote, On 31-7-2007 1:17:
>> Do you mean in the Page Load event?
[quoted text clipped - 32 lines]
>>>
>>> Jesse
Brandon Gano - 31 Jul 2007 04:40 GMT
Try to manually add Text="" in the aspx. Clearing the value in the
properties window probably removes the attribute from the control, which
would result in the value being shown by default (-1 in this case). Another
solution might be to use an empty value as well--unless your code
specifically requires -1 for unselected ddl values.
> Thanks that really helped. Just one problem to solve, even though I have
> deleted the Text value in the Items collection field, it still displays -1
[quoted text clipped - 39 lines]
>>>>
>>>> Jesse
Jesse Houwing - 31 Jul 2007 12:32 GMT
* Bill Gower wrote, On 31-7-2007 4:51:
> Thanks that really helped. Just one problem to solve, even though I have
> deleted the Text value in the Items collection field, it still displays -1
> in the drop down and I did check, I am displaying the proper field in the
> list.
I the past I've used as the text field. Not completely empty, but
it does the trick from a users perspective.
Jesse
>> * Bill Gower wrote, On 31-7-2007 1:17:
>>> Do you mean in the Page Load event?
[quoted text clipped - 31 lines]
>>>>
>>>> Jesse