Connecting Tech Pros Worldwide Help | Site Map

Unable to find control in Gridview

  #1  
Old June 28th, 2009, 05:03 PM
parshupooja's Avatar
Familiar Sight
 
Join Date: Jun 2007
Posts: 159
Hey All,
I have where I want to do some manipulations and show in other column but unable to find their values in RowDatabound event even though I have two records in gridview
Expand|Select|Wrap|Line Numbers
  1. <asp:GridView ID="GridView1" runat="server" ShowFooter="True" AutoGenerateColumns="false" Width="700px">
  2.         <Columns>
  3.                      <asp:TemplateField HeaderText="Qty">
  4.                         <EditItemTemplate>
  5.                             <asp:TextBox ID="TextBoxCode" runat="server" Width="20pt" Text='<%# Bind("Qty") %>'/>
  6.                         </EditItemTemplate>
  7.                         <ItemTemplate>
  8.                             <asp:Label ID="lblQty" runat="server" Text='<%# Eval("Qty") %>' />
  9.                         </ItemTemplate>
  10.                         <FooterTemplate>
  11.                             <asp:TextBox ID="TextQTY" runat="server" Width="20pt" Text='<%# Bind("Qty") %>'/>
  12.                         </FooterTemplate>
  13.                     </asp:TemplateField>                                
  14.                      <asp:TemplateField HeaderText="Unit Price">
  15.                       <EditItemTemplate>                            
  16.                         </EditItemTemplate>
  17.                         <ItemTemplate>
  18.                             <asp:Label ID="lblUnitCost" runat="server" Text='<%# Eval("UnitCost") %>' />
  19.                         </ItemTemplate>
  20.                         <FooterTemplate>
  21.                             <asp:Label ID="lblfooterUnitCost" runat="server" Text='<%# Eval("UnitCost") %>'/>
  22.                         </FooterTemplate>
  23.                     </asp:TemplateField>
  24.  <asp:TemplateField HeaderText="Line Total">
  25.                       <EditItemTemplate>
  26.  
  27.                         </EditItemTemplate>
  28.                         <ItemTemplate>
  29.                             <asp:Label ID="lbllinettl" runat="server" Text="" />
  30.                         </ItemTemplate>
  31.                         <FooterTemplate>
  32.                             <asp:Label ID="lblfooterLinePrice" runat="server" Text=""/>
  33.                         </FooterTemplate>
  34.                     </asp:TemplateField>
  35.                 </Columns>
  36.         </asp:GridView>     
  37.  
I want to do some calculations in gridview that is lbllinettl = lblUnitCost * lblQty
Here is my RowDAtaBound Event. I don't know why Qty is coming up blank

Expand|Select|Wrap|Line Numbers
  1. Protected Sub GridView1_RowDataBound(ByVal sender As Object,        If (e.Row.RowType = DataControlRowType.DataRow) Then ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
  2.  
  3.             Dim Qty As String
  4.             Qty = CType(e.Row.FindControl("lblQty"), Label).Text
  5.         End If
  6. end Sub
Thanks, Help appreciated
  #2  
Old June 28th, 2009, 05:26 PM
Newbie
 
Join Date: Jun 2009
Posts: 2

re: Unable to find control in Gridview


hi

Try using
Expand|Select|Wrap|Line Numbers
  1. ((Label)GridView1.Rows[0].Cells[0].Controls[5]).text
Hope it helps

Nitin
<link removed by moderator>

Last edited by insertAlias; June 29th, 2009 at 03:25 PM. Reason: use [CODE] tags and no signature links
Reply


Similar Threads
Thread Thread Starter Forum Replies Last Post
SqlDataSource control activating on button click Hrvoje Vrbanc answers 2 December 7th, 2007 09:55 AM
GridView, dynamic template fields, FindControl problem beton3000@gmail.com answers 4 September 2nd, 2007 08:25 PM
Unable To Insert The Data With Stored Procedure Using Sqldatasource,gridview sheenaa answers 1 April 6th, 2007 01:26 PM
get the rowindex in Gridview using Templatefield in ROWCOMMAND event Muhammad Saad Abbasi answers 1 February 28th, 2007 05:55 AM