Ask a Question related to ASP.NET General, Design and Development.
-
Chris #1
Adding a list item to the System.Web.UI.WebControls.DropDownList
I was wondering if there was any way to add a blank list
item control to the beginning of the
System.Web.UI.WebControls.DropDownList's datasource after
the control's datasource has been specified.
Here's my code right now:
Dim oEmptyOption as New ListItem()
'Assign datasource to delivery date type combobox
cboDeliveryDateType.DataSource = oDsDeliveryDateType.Tables
("DataTable")
cboDeliveryDateType.DataTextField =
oDsDeliveryDateType.Tables("DataTable").Columns.It em
("Display_Name").ToString()
cboDeliveryDateType.DataValueField =
oDsDeliveryDateType.Tables("DataTable").Columns.It em
("Delivery_Date_Type_ID").ToString()
cboDeliveryDateType.DataBind()
'Add empty option field
cboDeliveryDateType.Items.Add(oEmptyOption) 'adds to the
end of the list.
Currently, I am able to add the blank item at the end of
the controls Item's list, and select it as the default
selected item, but it appears as the last item in the drop
down list. I want to have it at the beginning of the list.
Any suggestions would be greatly appreciated.
Thanks,
Chris...
Chris Guest
-
add reference for System.Web.UI.webcontrols which dll?
Which dll should i add a reference to to get this. i've added System.Web.UI, but this does not give me WebControls. thanks kes -
can't set the selected item of the dropdownlist
I generate template columns in datagrid dynamic and I want dropdownlist in the EditItemTemplate, I did it But I can't set the selected item of... -
Change style of a single row of the item list of datagrid, based on a field value of current item...
Sorry for the long subject guys, but I don't know how better I can resume the matter... Anyway, I have my datagrid showing items of an order. I... -
System.Web.UI.WebControls Namespace
Does anyone have any sample code on code on creating tables/rows and cells using above namespace and adding checkbox controls to my cells? ... -
The type System.Web.UI.WebControls.TextBox in Assembly System.Web...error
I've been getting this error every since I installed InstallSqlState to handle my viewState Sessions. it only happens on 1 section of my asp.net... -
Elliot M. Rodriguez #2
Re: Adding a list item to the System.Web.UI.WebControls.DropDownList
Chris:
Try using Insert instead of Add - it takes the index to add the ListItem to,
and the ListItem object you want to add:
cboDeliveryDateType.Items.Insert(0, oEmptyOption)
HTH
--
Elliot M. Rodriguez, MCSD
*** It would take 227 cans of Mountain Dew to kill me***
"Chris" <chrisb@papex.com> wrote in message
news:80f701c3505b$fa023300$7d02280a@phx.gbl...> I was wondering if there was any way to add a blank list
> item control to the beginning of the
> System.Web.UI.WebControls.DropDownList's datasource after
> the control's datasource has been specified.
>
> Here's my code right now:
>
> Dim oEmptyOption as New ListItem()
>
> 'Assign datasource to delivery date type combobox
> cboDeliveryDateType.DataSource = oDsDeliveryDateType.Tables
> ("DataTable")
> cboDeliveryDateType.DataTextField =
> oDsDeliveryDateType.Tables("DataTable").Columns.It em
> ("Display_Name").ToString()
> cboDeliveryDateType.DataValueField =
> oDsDeliveryDateType.Tables("DataTable").Columns.It em
> ("Delivery_Date_Type_ID").ToString()
> cboDeliveryDateType.DataBind()
>
> 'Add empty option field
> cboDeliveryDateType.Items.Add(oEmptyOption) 'adds to the
> end of the list.
>
> Currently, I am able to add the blank item at the end of
> the controls Item's list, and select it as the default
> selected item, but it appears as the last item in the drop
> down list. I want to have it at the beginning of the list.
> Any suggestions would be greatly appreciated.
>
> Thanks,
>
> Chris...
Elliot M. Rodriguez Guest
-
Chris Barrow #3
Re: Adding a list item to the System.Web.UI.WebControls.DropDownList
Elliot,
Dead on. Thank you. Problem solved.
Thanks,
Chris...
*** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
Don't just participate in USENET...get rewarded for it!
Chris Barrow Guest



Reply With Quote

