Asp. NET Modify delete DataGrid row-database access
Last Update:2017-02-28
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>
<TD class= "title" valign= "Top" width= "429" colspan= "2" height= ">" Add a new publisher </td>
</tr>
<tr>
<TD valign= "Top" width= "height=" > Distributor id:</td>
<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>
<TD valign= "Top" width= "height=" ><font face= "song body" > Name:</font></td>
<TD valign= "Top" width= "height=" ><asp:textbox id= "TextBox2" runat= "Server" height= "18px" cssclass= " Smallred "></asp:textbox></td>
</tr>
<tr>
<TD valign= "Top" width= "height=" ><font face= "song body" > City:</font></td>
<TD valign= "Top" width= "height=" ><asp:textbox id= "TextBox3" runat= "Server" height= "18px" cssclass= " Smallred "></asp:textbox></td>
</tr>
<tr>
<TD valign= "Top" width= "height=" ><font face= "song body" > Province:</font></td>
<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>
<TD valign= "Top" width= "height=" ><font face= "song body" > National:</font></td>
<TD valign= "Top" width= "height=" ><asp:textbox id= "TextBox5" runat= "Server" height= "18px" cssclass= " Smallred "></asp:textbox></td>
</tr>
<tr>
<TD valign= "Top" align= "center" width= "429" colspan= "2" height= "><asp:linkbutton id=" LinkButton1 "runat=" Server > Submit to Database </asp:linkbutton></td>
</tr>
<tr>
<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)
{