Looping through a Listbox created on the fly
<p>I am working on exporting data and right now some fields export the value, instead of the text. So I am saving the object that returns the text and value to a list box and matching it to the value in the listbox from the object like so:</p>

<pre><code>MaterialDB materials = new MaterialDB();
DropDownList listBoxMaterials = new DropDownList();
listBoxMaterials.DataSource = materials.GetItems(ModuleId, TabId);
listBoxMaterials.DataBind();

string materialString = "";


foreach (ListItem i in listBoxMaterials.Items)
{
    if (i.Value == row["MaterialTypeID"].ToString())
    {
        materialString = i.Text;
    }
}
</code></pre>

<p>When I use this for the i.Value it always returns "System.Data.DataRowView" instead of the actual value. I'm doing this all in code behind. Anyway around this to get it to work?</p>

<p>Thanks!</p>
