How to edit datas in grigview.

Posted by Sathiya_Narayanan under ASP.NET on 8/7/2012 | Points: 10 | Views : 1004 | Status : [Member] | Replies : 4
Hi,
Function is editing in the gridview, when edit button is click it shows the row records in the popup box not in the same gridview.
for this i have used.

Here is the code..
<asp:BoundField DataField="username" HeaderText="Name"></asp:BoundField>

In .cs file
cmd.Parameters.AddWithValue("@username", txt_name.Text.Trim());

txt_name.Text = row.Cells[7].Text;

this works fine.. but when i convert the Bound field in to Template Field , its showing the datas in gridview. when i click edit button,
Ajax popup box opens but not displaying that text in that popup box from grid.

its not fetching datas from the grid to popup textbox.

<asp:TemplateField HeaderText="Customer">
<EditItemTemplate>
<asp:TextBox ID="txt_name" runat="server" Text='<%# Bind("Name") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lblname" runat="server" Text='<%# Bind(Name") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>

SATHIYANARAYANAN


Responses

Posted by: Sheonarayan on: 8/7/2012 [Administrator] HonoraryPlatinum | Points: 25

Up
0
Down
I think GridView doesn't work like this. It doesn't have any mechanism to automatically populate the data outside the GridView control. For that you will need to write custom code that will find the clicked row of the GridView and retrieve cells data and populate the popup textboxes. For this you can use jQuery. It has a lot of functions that allows you to do this.

The code snippet is big and lil complicated so can't write it here.

Regards,
Sheo Narayan
http://www.dotnetfunda.com

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

Posted by: Sathiya_Narayanan on: 8/7/2012 [Member] Starter | Points: 25

Up
0
Down
Ok thankyou sir.

SATHIYANARAYANAN

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

Posted by: Sathiya_Narayanan on: 8/7/2012 [Member] Starter | Points: 25

Up
0
Down
ok give me some other ideas to overcome that.
how to use in jQuery or any other methods.

SATHIYANARAYANAN

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

Posted by: Sathiya_Narayanan on: 8/10/2012 [Member] Starter | Points: 25

Up
0
Down
yeaah I got the answer for this..:)

SATHIYANARAYANAN

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

Login to post response