Controls ASP.NET

Radiobuttonlist

Fill with item and value

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

Dropdownlist

Fill with item and value

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

Results

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

Eventhandlers

In the aspx page

OnCheckedChanged="cbMale_OnCheckedChanged"
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

Gridview

Free controls

https://www.devexpress.com/Products/Free/NetOffer/
http://www.reflectionit.nl/Articles/SmartPart.aspx

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