开发者

Bind null value to a dropdown list

I am using items from sharepoint list to be binded to a dropdown list. However, I want the first value in the dropdown to be empty. I cannot insert a null value in the sharepoint list item.

开发者_运维问答

Please let me know how can I do it programmatically. Below is the code I am using to bind the list to dropdownlist

   if (Fldname.Contains("xxxxxx"))
            {
                ddllist.DataSource = data.getCode();
                ddllist.DataTextField = "Title";
                ddllist.DataValueField = "Alphabetic_x0020_Code";
                ddllist.DataBind();
                ddllist.SelectedValue = string.Empty;
                ddllist.Width = 120;
            }


there has to be something like this. Where 0 is the position you want the new item be - which is the first in this case. Can do this after the databinding.

ddllist.Items.Insert(0 , string.empty);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜