|
|
|
การดึงค่าจาก DataBase สู่ DropDrawListBox แบบมีค่าว่าง ต้องทำอย่างไรครับ |
|
|
|
|
|
|
|
มีตัวอย่างให้ดูครับ
Code (C#)
//*** Add/Insert Items ***//
void DropDownListAddInsertItem()
{
SortedList mySortedList = new SortedList();
mySortedList.Add("M","Man");
mySortedList.Add("W","Woman");
//*** DropDownList ***//
this.myDDL4.DataSource = mySortedList;
this.myDDL4.DataTextField = "Value";
this.myDDL4.DataValueField = "Key";
this.myDDL4.DataBind();
//*** Add & Insert New Item ***//
String strText,strValue;
//*** Insert Item ***//
strText = "";
strValue = "";
ListItem InsertItem = new ListItem(strText, strValue);
myDDL4.Items.Insert(0, InsertItem);
//*** Add Items ***//
strText = "Guy";
strValue = "G";
ListItem AddItem = new ListItem(strText, strValue);
myDDL4.Items.Add(AddItem);
//*** Default Value ***//
myDDL4.SelectedIndex = myDDL4.Items.IndexOf(myDDL4.Items.FindByValue("")); //*** By DataValueField ***//
//myDDL4.SelectedIndex = myDDL4.Items.IndexOf(myDDL4.Items.FindByText("")); //*** By DataTextField ***//
}
Go to : (C#) ASP.NET DropDownlist and DataBinding
|
|
|
|
|
Date :
2012-01-03 17:31:25 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบคุณครับผม
|
|
|
|
|
Date :
2012-01-03 19:36:43 |
By :
aekarita |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|