CodePaste Logo
New Snippet New Snippet Recent Snippets Recent Snippets My Snippets My Snippets Web Code Search Snippets Search
Sign inor Register
Language: C#

Read Repeater Items and its values

534 Views
Copy Code Show/Hide Line Numbers
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;
   }
by kannan M ambadi
  September 06, 2009 @ 11:13am
Tags:

Add a comment


Report Abuse
brought to you by:
West Wind Techologies



If you find this site useful and use it frequently please consider making a donation to support this free service.
Donate