Click here to Skip to main content
15,918,967 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
TextBox txt = (TextBox)GridView2.Rows [e.RowIndex].FindControl("txtQty");
        Label lbn = (Label)GridView2.Rows[e.RowIndex].FindControl("lblQty") as Label ;
       // lbn.Text = string.Empty;
        lbn.Text   =(txt.Text).ToString ();

   <asp:TemplateField>
                <EditItemTemplate>
                    <asp:TextBox ID="txtQty" runat="server"></asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="lblQty" runat="server"></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>

here i am enter text box value that i am clicking update button update value i need sir
Posted
Updated 6-Sep-12 20:45pm
v2

TextBox txt = (TextBox)GridView2.Rows [e.RowIndex].FindControl("txtQty");

I think you have error at this line due to e.rowindex check it is out of range 0 to gridview2.rows.count-1
Happy Coding!
:)
 
Share this answer
 
Hi,
This exception comes whenever you are trying to point an object which is null. Try this:
C#
TextBox txt = (TextBox)GridView2.Rows [e.RowIndex].FindControl("txtQty");
Label lbn = (Label)GridView2.Rows[e.RowIndex].FindControl("lblQty") ;
if(txt != null && lbn != null){
    // lbn.Text = string.Empty;
    lbn.Text   =txt.Text;
}



--Amit
 
Share this answer
 
v2
initialize component before use.
or Execute initialize() method of current from.
Happy Coding.:)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900