Hi I am trying to put an edit button in the grid view. My code looks like this View
Delete I was trying to do include another button called Edit .. which should enable user to edit the code. i am not able to use the asp.net inbuilt Edit feature in that. I even tried to use another link button and given the command name as edit. If i give like
this i am able to trigger the GridView_Rowediting event. But not able to get the buttons Update and Cancel when i click on the edit. Does any one have any clue ? Help me ......... Thanks in Advance
Better Post your code before asking a question. So that person helping u will understand u r problem Clearly
Yahoo IM : dotnetruler
I am trying to keep Frequently Asked Questions in my blog
While inserting i have added some required field validator in footer template.
I found out that footer control id are preceded with "-1" at clientSide which give javascript error on page. Also, because of this, no other script are able to fire on page. I am using VS 2010.
Any solution to avoid id to be preceded with -1.
Note: I am working on asp.net 4.0 Framework. This error is occured in project in same framework version. When i tested code in VS2008 web app project, it work properly with out any javascript error.
Man this is the best.After spending some time with java ;I just forgotten the crud functionality in GridView.Furthermore the color combinations you used are attracted enough to put more concentration right from the first line till the last line.Thanks and
regards
dotnetruler
Contributor
4230 Points
753 Posts
GridView custom Edit button...
Jan 06, 2009 07:29 PM|LINK
Delete I was trying to do include another button called Edit .. which should enable user to edit the code. i am not able to use the asp.net inbuilt Edit feature in that. I even tried to use another link button and given the command name as edit. If i give like this i am able to trigger the GridView_Rowediting event. But not able to get the buttons Update and Cancel when i click on the edit. Does any one have any clue ? Help me ......... Thanks in Advance
Yahoo IM : dotnetruler
I am trying to keep Frequently Asked Questions in my blog
ecbruck
All-Star
98783 Points
9691 Posts
Moderator
Re: GridView custom Edit button...
Jan 06, 2009 07:45 PM|LINK
Here's a full CRUD example for you that should help you out:
ASPX
<%@ page autoeventwireup="true" codefile="CRUDWithADO.aspx.cs" inherits="GridView_CRUDWithADO" language="C#" masterpagefile="~/MasterPages/Default.master" title="GridView: CRUD With ADO" %> <asp:content id="Content1" runat="Server" contentplaceholderid="ContentPlaceHolder1"> <asp:label id="lblMessage" runat="server" enableviewstate="false" /> <asp:gridview id="gvShippers" runat="server" allowpaging="True" allowsorting="True" autogeneratecolumns="False" datakeynames="ShipperID" emptydatatext="There are no data records to display." onpageindexchanging="gvShippers_PageIndexChanging" onrowcancelingedit="gvShippers_RowCancelingEdit" onrowcommand="gvShippers_RowCommand" onrowdeleting="gvShippers_RowDeleting" onrowediting="gvShippers_RowEditing" onrowupdating="gvShippers_RowUpdating" onsorting="gvShippers_Sorting" showfooter="true" style="margin-top: 20px;"> <columns> <asp:templatefield> <itemtemplate> <asp:linkbutton id="btnSelect" runat="server" commandname="Select" text="Select" /> <asp:linkbutton id="btnEdit" runat="server" commandname="Edit" text="Edit" /> <asp:linkbutton id="btnDelete" runat="server" commandname="Delete" text="Delete" /> </itemtemplate> <edititemtemplate> <asp:linkbutton id="btnUpdate" runat="server" commandname="Update" text="Update" /> <asp:linkbutton id="btnCancel" runat="server" commandname="Cancel" text="Cancel" /> </edititemtemplate> <footertemplate> <asp:linkbutton id="btnInsert" runat="server" commandname="Insert" text="Insert" /> </footertemplate> </asp:templatefield> <asp:boundfield datafield="ShipperID" headertext="ShipperID" insertvisible="false" readonly="true" sortexpression="ShipperID" /> <asp:templatefield headertext="CompanyName" sortexpression="CompanyName"> <itemtemplate> <%# Eval("CompanyName") %> </itemtemplate> <edititemtemplate> <asp:textbox id="txtCompanyName" runat="server" text='<%# Bind("CompanyName") %>' /> </edititemtemplate> <footertemplate> <asp:textbox id="txtCompanyName" runat="server" /> </footertemplate> </asp:templatefield> <asp:templatefield headertext="Phone" sortexpression="Phone"> <itemtemplate> <%# Eval("Phone") %> </itemtemplate> <edititemtemplate> <asp:textbox id="txtPhone" runat="server" text='<%# Bind("Phone") %>' /> </edititemtemplate> <footertemplate> <asp:textbox id="txtPhone" runat="server" /> </footertemplate> </asp:templatefield> </columns> </asp:gridview> </asp:content>CODE-BEHIND
Microsoft MVP - ASP.NET
dotnetruler
Contributor
4230 Points
753 Posts
Re: GridView custom Edit button...
Jan 06, 2009 07:56 PM|LINK
Yahoo IM : dotnetruler
I am trying to keep Frequently Asked Questions in my blog
sanketpathre
Member
317 Points
88 Posts
Re: GridView custom Edit button...
Dec 17, 2009 06:06 AM|LINK
Thanks for your answer.
I have found one problem with above code
While inserting i have added some required field validator in footer template.
I found out that footer control id are preceded with "-1" at clientSide which give javascript error on page. Also, because of this, no other script are able to fire on page. I am using VS 2010.
Any solution to avoid id to be preceded with -1.
Note: I am working on asp.net 4.0 Framework. This error is occured in project in same framework version. When i tested code in VS2008 web app project, it work properly with out any javascript error.
I have started new post on this problem :http://forums.asp.net/p/1505081/3570514.aspx#3570514
Chit Min Mau...
Member
79 Points
77 Posts
Re: GridView custom Edit button...
Apr 27, 2010 03:50 AM|LINK
Hi ecbruck,
Thanks for your post... And I just want to extend to combine column... How should I do that...
Now my grid is like this...
Company Name
Issued Date
Quotation1
Quotation2
Validity1
Validity2
ABC
27/04/2010
Q-01/ABC/2010
Q-02/ABC/2010
27/04/2010
27/05/2010
I want to be like this...
Company Name
Issued Date
Quotation1
Validity1
Quotation2
Validity2
ABC
27/04/2010
Q-01/ABC/2010
27/04/2010
Q-02/ABC/2010
27/05/2010
And I referenced based on your code...
but I used the data from database....
If you have any idea, pls give me advice... thx..
MCTS/ MCP
Analyst Programmer
http://www.cmmaung.me/
If this post helped you, please mark as Answer.
adeelgr8
Member
2 Points
1 Post
Re: GridView custom Edit button...
Nov 09, 2012 08:45 AM|LINK
Man this is the best.After spending some time with java ;I just forgotten the crud functionality in GridView.Furthermore the color combinations you used are attracted enough to put more concentration right from the first line till the last line.Thanks and regards