C# getting values from a listbox inside a gridview
i have a listbox in a grid and i'm trying to access the values populated in the listbox during the row updating event.
<ItemTemplate>
<asp:ListBox ID="InsuranceLB" runat="server" Width="225px" Height="75px" SelectionMode="Multiple" style="margin-top:2px;" autoscroll="true" /><br />
</ItemTemplate>
<ItemStyle VerticalAlign="Top" />
</asp:TemplateField>
This is how i'm trying to get the values
ListBox myListBox = (ListBox)GridView1.Rows[e.RowIndex].Cells[14].FindControl("InsuranceLB");
An error isn't thrown but i don't get the listbox values either. Any direction would be appreciated. Thanks in advance.
Thanks i figured it out, the problem was that the listbox really was empty lol. I wasn't populating it again in the edit event. Thanks for the response, both ways (with or without the cell reference) works to get the items in the listbox from a grid.
Gerry Bartley
Since you figured it your yourself, no need to award points. Just click request Attention to close the question and get your points back