I have a List of an object called \"Reasons\" that contains two properties \"Code\" & \"Text\". I want to use this to fill a UserControl of a Gridview. However, I don\
I don't really understand the sentence, "I want to use this to fill a UserControl of a Gridview."? However, if the question you are asking is how to bind a GridView to a list of your Reasons objects then this should work:
.aspx Page
Code Behind
protected void Page_Load(object sender, EventArgs e)
{
List reasonsList = new List()
{
new Reasons() { Code = "Code 1", Text = "Text 1" },
new Reasons() { Code = "Code 2", Text = "Text 2" },
new Reasons() { Code = "Code 3", Text = "Text 3" },
};
GridView1.DataSource = reasonsList;
GridView1.DataBind();
}
public class Reasons
{
public string Text { get; set; }
public string Code { get; set; }
}