selectedindexchanged

DropDownList OnSelectedIndexChange to 0th index w/out ViewState

≡放荡痞女 提交于 2019-12-04 22:06:31
问题 I did follow the article TRULLY Understanding ViewState (great article btw) and populating my drop down list is working great. I've even setup a OnSelectedIndexChange event which fires almost as great. The problem I've found is the SelectedIndexChanged event won't fire when selecting the 0th index. It does all other times however. Here's some code: <asp:DropDownList runat="server" ID="DropDownList1" EnableViewState="false" AutoPostBack="True" OnSelectedIndexChanged="DropDownList1

Dropdownlist selected value at Selectedindexchanged event

為{幸葍}努か 提交于 2019-12-04 03:18:17
I'm working on asp.net website with Vb.net and I have a dropdownlist with autopostback = true and I need to get the selected value when I change the item or I want to get the item which fires the selectedindexchanged event .. any help please.. In ie. your Page_Load set this.ComboBox1.SelectedIndexChanged += new System.EventHandler(ComboBox1_SelectedIndexChanged); Then write the event handler like this: private void ComboBox1_SelectedIndexChanged(object sender, System.EventArgs e) { ComboBox comboBox = (ComboBox) sender; string selected = (string) comboBox.SelectedItem; } Make sure that in your

DropDownList OnSelectedIndexChange to 0th index w/out ViewState

余生颓废 提交于 2019-12-03 15:08:36
I did follow the article TRULLY Understanding ViewState (great article btw) and populating my drop down list is working great. I've even setup a OnSelectedIndexChange event which fires almost as great. The problem I've found is the SelectedIndexChanged event won't fire when selecting the 0th index. It does all other times however. Here's some code: <asp:DropDownList runat="server" ID="DropDownList1" EnableViewState="false" AutoPostBack="True" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" /> protected override void OnInit(EventArgs e) { this.DropDownList1.DataTextField = "Text";

select same index in list box

点点圈 提交于 2019-12-02 12:23:03
I am making a website in asp.net and I have 2 list boxes: lbxPlayer1 and lbxPlayer2 lbxPlayer1.Items.Add("bob"); lbxPlayer1.Items.Add("jack"); lbxPlayer1.Items.Add("sam"); lbxPlayer2.Items.Add("fred"); lbxPlayer2.Items.Add("brian"); lbxPlayer2.Items.Add("dave"); they have both been populated with the same amount of values and i would like it so that when one of the lists is clicked the other list will select the same index. how do i do this? i assume the code would be in the lbxPlayer1_SelectedIndexChanged event? so when i click on "jack" i want "Brian" to also be selected. Use the

SelectedIndexChanged doesn't work!

好久不见. 提交于 2019-12-01 21:50:01
问题 My code: *.aspx: <asp:DropDownList ID="CountryList" CssClass="CountryList" runat="server" OnSelectedIndexChanged="CountryList_SelectedIndexChanged" /> *.aspx.cs: protected void Page_Load(object sender, EventArgs e) { CountryList.SelectedIndexChanged += new EventHandler(CountryList_SelectedIndexChanged); ... } protected void CountryList_SelectedIndexChanged(object sender, EventArgs e) { LoadCityList(CountryList, CityList); } But this doesn't work. 回答1: Try setting AutoPostBack="true" on this

ASP.NET / C#: DropDownList SelectedIndexChanged in server control not firing

空扰寡人 提交于 2019-11-30 13:22:45
问题 I'm creating a server control that basically binds two dropdown lists, one for country and one for state, and updates the state dropdown on the country's selectedindexchanged event. However, it's not posting back. Any ideas why? Bonus points for wrapping them in an UpdatePanel (having rendering issues; maybe because I don't have a Page to reference?) Here's what I have (with some extra data access stuff stripped out): public class StateProv : WebControl { public string SelectedCountry; public

How to avoid thousands of needless ListView.SelectedIndexChanged events?

岁酱吖の 提交于 2019-11-27 22:53:18
If a user select all items in a .NET 2.0 ListView, the ListView will fire a SelectedIndexChanged event for every item, rather than firing an event to indicate that the selection has changed. If the user then clicks to select just one item in the list, the ListView will fire a SelectedIndexChanged event for every item that is getting unselected, and then an SelectedIndexChanged event for the single newly selected item, rather than firing an event to indicate that the selection has changed. If you have code in the SelectedIndexChanged event handler, the program will become pretty unresponsive

Getting selected value of a combobox

你离开我真会死。 提交于 2019-11-27 12:37:37
public class ComboboxItem { public string Text { get; set; } public string Value { get; set; } public override string ToString() { return Text; } } private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { int selectedIndex = comboBox1.SelectedIndex; int selecteVal = (int)comboBox1.SelectedValue; ComboboxItem selectedCar = (ComboboxItem)comboBox1.SelectedItem; MessageBox.Show(String.Format("Index: [{0}] CarName={1}; Value={2}", selectedIndex, selectedCar.Text, selecteVal)); } I'm adding them like: ComboboxItem item = new ComboboxItem(); item.Text = cd.Name; item.Value = cd.ID;

DropDownList's SelectedIndexChanged event not firing

只愿长相守 提交于 2019-11-27 06:13:04
I have a DropDownList object in my web page. When I click on it and select a different value, nothing happens, even though I have a function wired up to the SelectedIndexChanged event. I'll try and post my code here as orderly as possible: First, the actual object's HTML code: <asp:DropDownList ID="logList" runat="server" onselectedindexchanged="itemSelected"> </asp:DropDownList> And this is that function, itemSelected : protected void itemSelected(object sender, EventArgs e) { Response.Write("Getting clicked; " + sender.GetType().ToString()); FileInfo selectedfile; Response.Write("<script

How to avoid thousands of needless ListView.SelectedIndexChanged events?

▼魔方 西西 提交于 2019-11-26 21:13:03
问题 If a user select all items in a .NET 2.0 ListView, the ListView will fire a SelectedIndexChanged event for every item, rather than firing an event to indicate that the selection has changed. If the user then clicks to select just one item in the list, the ListView will fire a SelectedIndexChanged event for every item that is getting unselected, and then an SelectedIndexChanged event for the single newly selected item, rather than firing an event to indicate that the selection has changed. If