not getting the value from gridview cell while rowupdating event

Posted by Kranti under C# on 4/7/2012 | Points: 10 | Views : 4169 | Status : [Member] | Replies : 1
Hi,

I am trying to retrieve the value from gridview cell in rowediting event.It taking system.web.ui.control.Textbox.

<asp:GridView ID="gdpopulate" runat="server" AutoGenerateEditButton="True" DataKeyNames="P_Id" OnRowEditing="gdpopulate_RowEditing" AutoGenerateColumns="False" OnRowUpdating="gdpopulate_RowUpdating" OnRowUpdated="gdpopulate_RowUpdated" >
<Columns>
<asp:BoundField DataField="P_Id" HeaderText="PID" ReadOnly="True" />

<asp:TemplateField HeaderText="Firstname">

<ItemTemplate >

<%# Eval("Firstname")%>

</ItemTemplate>

<EditItemTemplate>

<asp:TextBox ID="txtfname" runat="Server" Text='<%# Eval("Firstname") %>' Columns="30" ></asp:TextBox>

<asp:RequiredFieldValidator ID="req1" runat="Server" Text="*" ControlToValidate="txtfname"></asp:RequiredFieldValidator>

</EditItemTemplate>

</asp:TemplateField>
</Columns>
</asp:GridView>

C# code

GridViewRow var = (GridViewRow)gdpopulate.Rows[e.RowIndex];
int pid =Int32.Parse (gdpopulate.DataKeys[e.RowIndex].Value.ToString());
TextBox tfname = (TextBox)gdpopulate.Rows[e.RowIndex].FindControl("txtfname") ;
//TextBox tfname = (TextBox)var.FindControl("txtfname");

help me as soon as possible




Responses

Posted by: Hariinakoti on: 4/9/2012 [Member] Starter | Points: 25

Up
0
Down
u can use gridview1.databind();
all the values of gridview update.

Thanks & Regards
Hari

Kranti, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response