Easy to use click and double-click to update the data in the DataGrid example

Source: Internet
Author: User
Tags datagrid example visual studio
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;



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.