Controls ASP.NET


Fill with item and value

RadioButtonList1.DataSource = CreateDataSource()
RadioButtonList1.DataTextField = "StringValue"
RadioButtonList1.DataValueField = "CurrencyValue"
strString = RadioButtonList1.SelectedItem.Text
value = RadioButtonList1.SelectedItem.Value


Fill with item and value

ddlCustomer.Items.Add(new ListItem(itemText, itemValue));
The itemText is shown on the screen, the itemValue is the 'key'.


result modes
.SelectedIndex position of the selected item in the list, first item = 0 get, set
.SelectedItem selected ListItem, so has .Text and .Value get
.SelectedValue Value of the selected ListItem, so = SelectedItem.Value get, set
.Text Value of the selected ListItem, so = SelectedItem.Value get, set


In the aspx page

protected void cbMale_OnCheckedChanged(object sender, EventArgs e) { }

Mind: has to be protected, if not the page can hang!

Adding in code

cbFinanced.CheckedChanged += new EventHandler(this.cbFeeFinanced_Click);
Take care: AutoPostBack for this control has to be true!
Mind that dynamically generated controls disappear after a Postback


Free controls

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License