Link to home
Start Free TrialLog in
Avatar of national_fulfillment
national_fulfillmentFlag for United States of America

asked on

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.  
 <asp:ListBox ID="InsuranceLB" runat="server" Width="225px" Height="75px" SelectionMode="Multiple" style="margin-top:2px;" autoscroll="true"  /><br />
     <ItemStyle VerticalAlign="Top" />

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.
Avatar of Gerry Bartley
Gerry Bartley
Flag of Ireland image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of national_fulfillment


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.
Since you figured it your yourself, no need to award points. Just click request Attention to close the question and get your points back