Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Post
Register
Login
2
Reply
how can i set all the items to dropdownList
Cassie Mod
Jan 3 2017 9:53 AM
231
Reply
HI ive got the following code.
protected
void
AdditionalDevice_ItemCommand(
object
source, RepeaterCommandEventArgs e)
{
// set all your asp controls (label, ddl, textbox.etc)
DropDownList ddlAdditionalDevicesEdit;
try
{
switch
(e.CommandName)
{
case
"Edit"
:
// hide labels
var label = (Label)e.Item.FindControl(
"lblDeviceType"
);
var macadreslabel = (Label)e.Item.FindControl(
"lblMacAdressDevice"
);
label.Visible =
false
;
macadreslabel.Visible =
false
;
// set the value of the Label in the ddl
//foreach (var item in AdditionalDevices.Items)
//{
// var result = (DropDownList)e.Item.FindControl("additionalDeviceDropDownList");
// ddlAdditionalDevicesEdit.Items.Add(result.SelectedItem.Text);
//}----> not working!!!
ddlAdditionalDevicesEdit = (DropDownList)e.Item.FindControl(
"additionalDeviceDropDownList"
); --->
this
is
showing only one result i need to have all of them
// show ddl
ddlAdditionalDevicesEdit.Visible =
true
;
// show textbox
var macAdressTextBox = (TextBox)e.Item.FindControl(
"deviceMacAdressTextBox"
);
macAdressTextBox.Text = macadreslabel.Text;
macAdressTextBox.Visible =
true
;
// hide edit_button
((Button)e.Item.FindControl(
"additionaldevice_editbutton"
)).Visible =
false
;
// Hide delete button
((Button)e.Item.FindControl(
"additionaldevicedeleteButton"
)).Visible =
false
;
// show submit_button
((Button)e.Item.FindControl(
"additionaldevicesubmitbutton"
)).Visible =
true
;
// show cancel_button
((Button)e.Item.FindControl(
"additionaldeviceCancelButton"
)).Visible =
true
;
// Hide rows wich are not editted
foreach
(RepeaterItem item
in
AdditionalDevices.Items)
{
if
((item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem) &&
(e.Item.ItemIndex != item.ItemIndex))
{
item.FindControl(
"additionaldevice_editbutton"
).Visible =
false
;
item.FindControl(
"additionaldevicedeleteButton"
).Visible =
false
;
}
}
break
;
case
"Submit"
:
break
;
case
"Delete"
:
break
;
}
}
catch
(Exception ex)
{
App.HandleException(ex);
ShowFailureText();
}
}
However the line ddlAdditionalDevicesEdit = (DropDownList)e.Item.FindControl("additionalDeviceDropDownList"); is only setting one of the two items to the dropdownlist, how can i add both of them ???
thnx
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
2
)
Next Recommended Forum
Database dont update from gridview templatefield
Changing the Back Color of Selected Row