Language: C#
Read Repeater Items and its values
private T GetRepeaterItemValue<T>(RepeaterItem item, string controlId) { T controlValue = default(T); if (item != null && !String.IsNullOrEmpty(controlId)) { var control = item.FindControl(controlId); if (control is DropDownList) { controlValue = (T)Convert.ChangeType(((DropDownList)control).SelectedValue, typeof(T)); } else if (control is TextBox) { controlValue = (T)Convert.ChangeType(String.IsNullOrEmpty(((TextBox)control).Text) ? String.Empty : ((TextBox)control).Text.Trim(), typeof(T)); } else if (control is HiddenField) { controlValue = (T)Convert.ChangeType(((HiddenField)control).Value, typeof(T)); } } return controlValue; }
Tags:
Report Abuse
Subscribe
Discuss
What's new
What is it
New Snippet
Recent Snippets
My Snippets
Web Code
Search

