Asp. NET Modify delete DataGrid row-database access

Source: Internet
Author: User
asp.net|datagrid| Access | data | Database Create a Web page, named: add.aspx.
  
Add.aspx Code:
  
<%@ Page language= "C #" codebehind= "Add.aspx.cs" autoeventwireup= "false" inherits= " TeachShow.Charpter7.AccessDataBase.Add "%>
  
<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 transitional//en" >
  
<HTML>
  
<HEAD>
  
<title>Add</title>
  
<link href= ". /.. /style.css "type=" Text/css "rel=" stylesheet ">
  
<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" >
  
</HEAD>
  
<body ms_positioning= "GridLayout" >
  
<form id= "Form1" method= "POST" runat= "Server" >
  
<div align= "center" >
  
<center>
  
<table class= "Smallblack" height= "318" cellspacing= "0" cellpadding= "0" width= "429" border= "0" >
  
<tr>
  
&LT;TD class= "title" valign= "Top" width= "429" colspan= "2" height= ">" Add a new publisher </td>
  
</tr>
  
<tr>
  
&LT;TD valign= "Top" width= "height=" > Distributor id:</td>
  
&LT;TD valign= "Top" width= "height=" ><asp:textbox id= "TextBox1" runat= "Server" height= "18px" cssclass= " Smallred "></asp:textbox><font face=" > (with 99, total 4 digits) </FONT></td>
  
</tr>
  
<tr>
  
&LT;TD valign= "Top" width= "height=" ><font face= "song body" > Name:</font></td>
  
&LT;TD valign= "Top" width= "height=" ><asp:textbox id= "TextBox2" runat= "Server" height= "18px" cssclass= " Smallred "></asp:textbox></td>
  
</tr>
  
<tr>
  
&LT;TD valign= "Top" width= "height=" ><font face= "song body" > City:</font></td>
  
&LT;TD valign= "Top" width= "height=" ><asp:textbox id= "TextBox3" runat= "Server" height= "18px" cssclass= " Smallred "></asp:textbox></td>
  
</tr>
  
<tr>
  
&LT;TD valign= "Top" width= "height=" ><font face= "song body" > Province:</font></td>
  
&LT;TD valign= "Top" width= "height=" ><asp:textbox id= "TextBox4" runat= "Server" height= "18px" cssclass= " Smallred "></asp:textbox><font face=" XXFarEastFont-Arial > (2 characters) </FONT></td>
  
</tr>
  
<tr>
  
&LT;TD valign= "Top" width= "height=" ><font face= "song body" > National:</font></td>
  
&LT;TD valign= "Top" width= "height=" ><asp:textbox id= "TextBox5" runat= "Server" height= "18px" cssclass= " Smallred "></asp:textbox></td>
  
</tr>
  
<tr>
  
&LT;TD valign= "Top" align= "center" width= "429" colspan= "2" height= "><asp:linkbutton id=" LinkButton1 "runat=" Server > Submit to Database </asp:linkbutton></td>
  
</tr>
  
<tr>
  
&LT;TD width= "429" height= "147" valign= "Top" colspan= "2" >
  
<asp:datagrid id= "DATAGRID1" runat= "Server" height= "120px" cssclass= "General" width= "428px" >
  
<itemstyle width= "50px" ></ItemStyle>
  
<Columns>
  
<asp:editcommandcolumn buttontype= "LinkButton" updatetext= "Update" canceltext= "Cancel" edittext= "edit" >
  
  
</asp:EditCommandColumn>
  
<asp:buttoncolumn text= "Delete" commandname= "delete" ></asp:ButtonColumn>
  
</Columns>
  
</asp:DataGrid></td>
  
</tr>
  
</table>
  
</center>
  
</div>
  
</form>
  
</body>
  
</HTML>
  
Add.asp.cs Code:
  
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 TeachShow.Charpter7.AccessDataBase
  
{
  
<summary>
  
ADD's summary description.
  
</summary>
  
public class Add:System.Web.UI.Page
  
{
  
protected System.Web.UI.WebControls.TextBox TextBox1;
  
protected System.Web.UI.WebControls.TextBox TextBox2;
  
protected System.Web.UI.WebControls.TextBox TextBox3;
  
protected System.Web.UI.WebControls.TextBox TextBox4;
  
protected System.Web.UI.WebControls.LinkButton LinkButton1;
  
protected System.Web.UI.WebControls.DataGrid DataGrid1;
  
protected System.Web.UI.WebControls.TextBox TextBox5;
  
private void Page_Load (object sender, System.EventArgs e)
  
{
  
Place user code here to initialize page
  
if (!this. IsPostBack)
  
{
  
This. Bindgrid ();
  
}
  
}
  
Code generated #region the Web forms Designer
  
Override protected void OnInit (EventArgs e)
  
{

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.