![]() |
| ||
| Dropdown list Last value I fill dropdown lists values from the database then I wants to hard code first value and last value. I already hard code first value it's like this. cboName.Items.Insert(0,new ListItem("----Select----","0")); how can I hard code last value of the dropdown list, I want to add last value as a ----Other----. can anyone help me? Thanks. |
| ||
| Re: Dropdown list Last value Do a count of the number of ListItems, and then store that in a variable and add 1 and then add your last value = Other example: nCount = {count of the number of item entries in the dropdownlist} cboName.Items.Insert(nCount + 1,new ListItem("OTHER","0")); Hope this helps |
| ||
| Re: Dropdown list Last value Yes,it works thanks. |
| ||
| Re: Dropdown list Last value I believe you can also do the following: cboName.Items.Add(new listitem("Other","0")) 'item_name' would be the name of the item you want to add And, another option for hard-coding the first entry, or the first several entries is to add the entries on the actual .aspx page in the <asp:listitem> tags, and then set the cboName's AppendDataBoundItems property to true. Though that's just a personal preference. |
| All times are GMT -4. The time now is 9:48 am. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC