SirReadAlot
asked on
DropDownlist control
Morning guys,
I am carrying out an update on a dropdown control with works perfectly.
So when a user selects an item from the dropdown it updates in the
database. But on pageload I what the new selected item to be visible
and not default item on the dropdown.
EXAMPLE.
1)original item on the dropdown is A,
2)the new selected item is B
3)but on pageload it defaults to A, BUT SHOULD BE B.
thanks guys
public void dgCompensation_ItemDataBou nd(Object Sender, DataGridItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.EditItem)
{
DataRowView objDataRowView = (DataRowView)e.Item.DataIt em;
string currentDeduction = (string)objDataRowView[2]. ToString() ;
DropDownList ctlDropDownList = (DropDownList)e.Item.FindC ontrol("De ductDropDo wnList");
if (ctlDropDownList != null)
{
ctlDropDownList.Items.Add( "Y");
ctlDropDownList.Items.Add( "N");
ctlDropDownList.Items.Add( "E");
}
ctlDropDownList.SelectedIn dex = ctlDropDownList.Items.Inde xOf(ctlDro pDownList. Items.Find ByText(cur rentDeduct ion));
}
}
I am carrying out an update on a dropdown control with works perfectly.
So when a user selects an item from the dropdown it updates in the
database. But on pageload I what the new selected item to be visible
and not default item on the dropdown.
EXAMPLE.
1)original item on the dropdown is A,
2)the new selected item is B
3)but on pageload it defaults to A, BUT SHOULD BE B.
thanks guys
public void dgCompensation_ItemDataBou
{
if (e.Item.ItemType == ListItemType.EditItem)
{
DataRowView objDataRowView = (DataRowView)e.Item.DataIt
string currentDeduction = (string)objDataRowView[2].
DropDownList ctlDropDownList = (DropDownList)e.Item.FindC
if (ctlDropDownList != null)
{
ctlDropDownList.Items.Add(
ctlDropDownList.Items.Add(
ctlDropDownList.Items.Add(
}
ctlDropDownList.SelectedIn
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
string s = "N";
ctlDropDownList.Items.Add( "Y");
ctlDropDownList.Items.Add( "N");
ctlDropDownList.Items.Add( "E");
int i = ctlDropDownList.FindContro l(s);===== ====> there is no findcontrol for string
ctlDropDownList.SelectedIn dex = i;
thanks,
I fink the dropdown should default to whats on the datagrid
thanks
ctlDropDownList.Items.Add(
ctlDropDownList.Items.Add(
ctlDropDownList.Items.Add(
int i = ctlDropDownList.FindContro
ctlDropDownList.SelectedIn
thanks,
I fink the dropdown should default to whats on the datagrid
thanks
ASKER