TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Cassie Mod
NA
488
70.1k
how can i set all the items to dropdownList
Jan 3 2017 9:53 AM
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
Reply
Answers (
2
)
Database dont update from gridview templatefield
Changing the Back Color of Selected Row