datagrid| data
Maybe when you're using the DataGrid to edit the data, it's not convenient to click on the last Edit Column button to modify the data. In today's example, a more convenient way to do this is to modify the data by clicking on the line-the text box in which the mouse is placed and the contents of the text box will be selected. Can be modified directly-"After the modification, double-click this line (you can also double-click the text box) to save. This time using the Employees table in the Northwind database in the SQL Server database as an example.
Front desk:
<%@ Page language= "C #" codebehind= "WebForm87.aspx.cs" autoeventwireup= "false" inherits= "csdn. WebForm87 "%>
<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 transitional//en" >
<HTML>
<HEAD>
<title>WebForm87</title>
<meta content= "Microsoft Visual Studio. NET 7.1" name= "generator" >
<meta content= "C #" Name= "Code_language" >
<meta content= "JavaScript" name= "vs_defaultClientScript" >
<meta content= "http://schemas.microsoft.com/intellisense/ie5" name= "Vs_targetschema" >
<link href= "Css.css" type= "Text/css" rel= "stylesheet" >
</HEAD>
<body>
<form id= "Form1" method= "POST" runat= "Server" >
<asp:datagrid id= "DATAGRID1" runat= "Server" autogeneratecolumns= "False" cellspacing= "1" borderwidth= "0px"
cellpadding= "5" cssclass= "border" datakeyfield= "EmployeeID" >
<itemstyle cssclass= "Item" ></ItemStyle>
<Columns>
<asp:boundcolumn datafield= "FirstName" headertext= "FirstName" ></asp:BoundColumn>
<asp:boundcolumn datafield= "LastName" headertext= "LastName" ></asp:BoundColumn>
<asp:boundcolumn datafield= "title" headertext= "title" ></asp:BoundColumn>
<asp:boundcolumn datafield= "Birthdate" headertext= "birthdate" dataformatstring= "{0:yyyy-MM-dd}" ></asp: Boundcolumn>
<asp:buttoncolumn buttontype= "LinkButton" commandname= "edit" text= "edit" visible= "False" ></asp: Buttoncolumn>
<asp:buttoncolumn buttontype= "LinkButton" commandname= "Update" text= "Update" visible= "False" ></asp: Buttoncolumn>
</Columns>
</asp:datagrid>
</form>
</body>
</HTML>
Background:
Using System;
Using System.Collections;
Using System.ComponentModel;
Using System.Data;
Using System.Data.SqlClient;
Using System.Drawing;
Using System.Web;
Using System.Web.SessionState;
Using System.Web.UI;
Using System.Web.UI.WebControls;
Using System.Web.UI.HtmlControls;
Namespace Csdn
{
public class WebForm87:System.Web.UI.Page
{
protected System.Web.UI.WebControls.DataGrid DataGrid1;