title: How to get value from a listview Asp.Net
body: <p>I have a listview in asp.net like this:</p>
  
  <pre><code>&lt;asp:ListView ID="lvLoads" DataKeyNames="BookingId" OnItemCommand="lvLoads_OnItemCommand" runat="server"&gt;
              &lt;EmptyDataTemplate&gt;
                  &lt;table&gt;
                      &lt;tr&gt;
                          &lt;td&gt;No data was returned.&lt;/td&gt;
                      &lt;/tr&gt;
                  &lt;/table&gt;
              &lt;/EmptyDataTemplate&gt;
              &lt;GroupTemplate&gt;
                  &lt;asp:PlaceHolder ID="itemPlaceholder" runat="server"&gt;&lt;/asp:PlaceHolder&gt;
              &lt;/GroupTemplate&gt;
              &lt;ItemTemplate&gt;
                  &lt;fieldset&gt;
                      &lt;table class="table table-striped table-responsive"&gt;
                          &lt;thead&gt;
                              &lt;tr class="hidden-lg"&gt;
                                  &lt;th width="15%"&gt;Type&lt;/th&gt;
                                  &lt;th width="31%"&gt;Details&lt;/th&gt;
                                  &lt;th width="25%"&gt;Distance/Duration&lt;/th&gt;
                                  &lt;th width="21%"&gt;&amp;nbsp;&lt;/th&gt;
                              &lt;/tr&gt;
                          &lt;/thead&gt;
                          &lt;tbody&gt;
                              &lt;tr&gt;
                                  &lt;td width="15%"&gt;
                                      &lt;asp:Label CssClass="hide" ID="lblBokingId" runat="server"&gt;&lt;%# Eval("BookingId") %&gt;&lt;/asp:Label&gt;             
  
                  &lt;asp:Label ID="lblLoadTypeName" runat="server"&gt; &lt;%# Eval("LoadTypeName") %&gt;&lt;/asp:Label&gt;
                                      &lt;br&gt;
                                  &lt;/td&gt;
                                  &lt;td width="21%"&gt;
                                    &lt;asp:LinkButton ID="btnViewMore" CssClass="btn btn-warning" CommandName="ViewMore" runat="server"&gt;View More&lt;/asp:LinkButton&gt;
                                  &lt;/td&gt;
                              &lt;/tr&gt;
                          &lt;/tbody&gt;
                      &lt;/table&gt;
                  &lt;/fieldset&gt;
              &lt;/ItemTemplate&gt;
          &lt;/asp:ListView&gt;
  </code></pre>
  
  <p>Now on click of the button ViewMore i wrote this code to extract listviewItem's value:</p>
  
  <pre><code>var id = ((Label)e.Item.FindControl("lblBookingId")).Text;
  var name = ((Label)e.Item.FindControl("lblLoadTypeName")).Text;
  </code></pre>
  
  <p>But <code>e.Item.FindControl("lblBookingId")</code> always comes null. I checked the page's html by using inspect element of chrome, and i was shocked to see that my id somehow got changed to <code>ContentSection_ctl00_lblLoadTypeName_0</code></p>
  
  <p>I am really stuck at this. Please help me. Thanx in Advance</p>