This is a discussion on How to edit grid view control in asp.net using c#? within the ASP and ASP.NET Programming forums, part of the Web Development category; How to edit grid view control in asp.net using c#?...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| We have to write in example1.aspx page. <%@ Page Language="C#" %> <html> <head runat="server"> <title>Updating Data Using GridView</title> </head> <body> <form id="form1" runat="server"> <asp:GridView ID="GridView1" AllowSorting="true" AllowPaging="true" Runat="server" DataSourceID="SqlDataSource1" AutoGenerateEditButton="true" DataKeyNames="au_id" AutoGenerateColumns="False"> <Columns> <asp:BoundField ReadOnly="true" HeaderText="ID" DataField="au_id" SortExpression="au_id" /> <asp:BoundField HeaderText="Last Name" DataField="au_lname" SortExpression="au_lname" /> <asp:BoundField HeaderText="First Name" DataField="au_fname" SortExpression="au_fname" /> <asp:BoundField HeaderText="Phone" DataField="phone" SortExpression="phone" /> <asp:BoundField HeaderText="Address" DataField="address" SortExpression="address" /> <asp:BoundField HeaderText="City" DataField="city" SortExpression="city" /> <asp:BoundField HeaderText="State" DataField="state" SortExpression="state" /> <asp:BoundField HeaderText="Zip Code" DataField="zip" SortExpression="zip" /> <asp:CheckBoxField HeaderText="Contract" SortExpression="contract" DataField="contract" /> </Columns> </asp:GridView> <asp:SqlDataSource ID="SqlDataSource1" Runat="server" SelectCommand="SELECT [au_id], [au_lname], [au_fname], [phone], [address], [city], [state], [zip], [contract] FROM [authors]" UpdateCommand="UPDATE [authors] SET [au_lname] = @au_lname, [au_fname] = @au_fname, [phone] = @phone, [address] = @address, [city] = @city, [state] = @state, [zip] = @zip, [contract] = @contract WHERE [au_id] = @au_id" ConnectionString="<%$ ConnectionStrings:Pubs %>" /> </form> </body> </html> These following code is to be write in Web config file <?xml version="1.0"?> <configuration> <connectionStrings> <!-- This connection is inherited from the ASP.NET Quickstart Web.config file Uncomment this section to edit the sample locally <add name="Pubs" connectionString="Server=(local)\SQLExpress;Integr ated Security=True;Database=pubs;Persist Security Info=True" providerName="System.Data.SqlClient" /> <add name="Northwind" connectionString="Server=(local)\SQLExpress;Integr ated Security=True;Database=Northwind;Persist Security Info=True" providerName="System.Data.SqlClient" /> <add name="Contacts" connectionString="Server=(local)\SQLExpress;Integr ated Security=True;Database=Contacts;Persist Security Info=True" providerName="System.Data.SqlClient" /> --> <add name="NorthwindOLEDB" connectionString="Provider=Microsoft.Jet.OLEDB.4.0 ;Data Source=|DataDirectory|Northwind.mdb;" providerName="System.Data.OleDb" /> <add name="ContactsDatabase" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirector y|Database.mdf;Integrated Security=True;User Instance=true;" providerName="System.Data.SqlClient" /> </connectionStrings> <system.web> <pages styleSheetTheme="Default"/> <caching> <sqlCacheDependency enabled="true" pollTime="1000"> <databases> <add name="Pubs" connectionStringName="Pubs"/> </databases> </sqlCacheDependency> </caching> </system.web> </configuration> |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Edit grid | Kirubhananth | ASP and ASP.NET Programming | 7 | 11-14-2008 05:08 AM |
| Showing the Image file thumbnail view in ListView control using VC++ 6.0 | prabhat.singh | C and C++ Programming | 0 | 01-17-2008 10:53 PM |
| Grid View Control in asp.net | krishnakumar | ASP and ASP.NET Programming | 3 | 09-27-2007 03:18 AM |
| use of Custom Control and User Control? | a.deeban | ASP and ASP.NET Programming | 1 | 08-20-2007 08:25 AM |
| How can we get the text from edit control in Win32 VC++ application? | mobilegeek | C and C++ Programming | 1 | 07-25-2007 11:27 PM |