IT Community - Software Programming, Web Development and Technical Support

How to edit grid view control in asp.net using c#?

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#?...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > ASP and ASP.NET Programming

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 07-25-2007, 05:38 AM
bluesky bluesky is offline
D-Web Analyst
 
Join Date: Jun 2007
Posts: 201
bluesky is on a distinguished road
Question How to edit grid view control in asp.net using c#?

How to edit grid view control in asp.net using c#?
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-25-2007, 05:54 AM
kingmaker kingmaker is offline
D-Web Genius
 
Join Date: Jun 2007
Posts: 882
kingmaker is on a distinguished road
Send a message via Yahoo to kingmaker
Default Re: How to edit grid view control in asp.net using c#?

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>
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


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


All times are GMT -7. The time now is 08:06 AM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0