Answered by:
HELPPP!! Edit/Update/Delete

Question
-
User1784487500 posted
Does anyone know the CODES for making the "Edit/Delete/Select" of table WORKBLE to successfully update the table?
Because the edit is not working and need to insert datacode something in order to make the "Edit/Update" workable?
Please Do Help Genius~~~
Here is the "Aspx.cs"
This is the Web.config
Monday, February 6, 2012 11:56 PM
Answers
-
User803630265 posted
u use this code
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Petent.aspx.cs" Inherits="Petent" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div style="table-layout: auto; background-color: #ccff66">
<br />
<br />
<br />
<br />
<asp:Label ID="Label1" runat="server" BackColor="Transparent" BorderColor="Transparent" Font-Bold="True" Font-Italic="True" Font-Names="Gautami"
Font-Size="XX-Large" Font-Strikeout="False" Font-Underline="True" ForeColor="BlueViolet"
Height="49px" Text="Nawada Public Grievance Redressal System" Width="608px"></asp:Label>
<br />
<br />
<br />
<br />
<asp:Label ID="Label2" runat="server" BackColor="Transparent"
BorderColor="Transparent" BorderStyle="None" Font-Size="Medium" ForeColor="BlueViolet"
Text="Full Name"></asp:Label>
<asp:TextBox ID="TextBoxFullname" runat="server" Font-Size="Medium" Width="186px"></asp:TextBox>
<asp:Label ID="Label3" runat="server" BackColor="Transparent" BorderColor="Transparent" BorderStyle="None"
Font-Size="Medium" ForeColor="BlueViolet" Text="Gender"></asp:Label>
<asp:TextBox ID="TextBoxgender" runat="server" Width="43px"></asp:TextBox>
<asp:Label ID="Label4" runat="server" BackColor="Transparent" BorderColor="Transparent" BorderStyle="None"
Font-Size="Medium" ForeColor="BlueViolet" Text="Address1"></asp:Label>
<asp:TextBox ID="TextBoxadd1" runat="server" Width="162px"></asp:TextBox><br />
<br />
<asp:Label ID="Label5" runat="server" BackColor="Transparent" BorderColor="Transparent" BorderStyle="None"
Font-Size="Medium" ForeColor="BlueViolet" Text="Address2" Width="71px"></asp:Label>
<asp:TextBox ID="TextBoxadd2" runat="server" Width="185px"></asp:TextBox>
<asp:Label ID="Label6" runat="server" BackColor="Transparent"
BorderColor="Transparent" BorderStyle="None" Font-Size="Medium" ForeColor="BlueViolet"
Text="Address3"></asp:Label>
<asp:TextBox ID="TextBoxadd3" runat="server" Width="302px"></asp:TextBox>
<br />
<br />
<asp:Label ID="Label7" runat="server" BackColor="Transparent"
BorderColor="Transparent" BorderStyle="None" Font-Size="Medium" ForeColor="BlueViolet"
Text="Block" Width="55px"></asp:Label>
<asp:DropDownList ID="DropDownList1" runat="server"
AutoPostBack="True" DataSourceID="SqlDataSource1" DataTextField="block"
DataValueField="block">
</asp:DropDownList>
<asp:Label ID="Label8" runat="server" BackColor="Transparent"
BorderColor="Transparent" BorderStyle="None" Font-Size="Medium" ForeColor="BlueViolet"
Text="Panchayat"></asp:Label>
<asp:TextBox ID="TextBoxpanchayat" runat="server"></asp:TextBox>
<asp:Label ID="Label9" runat="server" BackColor="Transparent" BorderColor="Transparent" BorderStyle="None"
Font-Size="Medium" ForeColor="BlueViolet" Text="Village"></asp:Label>
<asp:TextBox ID="TextBoxvillage" runat="server" Width="162px"></asp:TextBox>
<br />
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:jantadarbarnwdConnectionString7 %>"
SelectCommand="SELECT [block] FROM [block]"></asp:SqlDataSource>
<br />
<asp:Label ID="Label10" runat="server" BackColor="Transparent"
BorderColor="Transparent" BorderStyle="None" Font-Size="Medium" ForeColor="BlueViolet"
Text="Phone/Mobile"></asp:Label> <asp:TextBox ID="TextBoxphone_mobile"
runat="server" OnTextChanged="TextBoxphone_mobile_TextChanged"></asp:TextBox>
<asp:Label ID="Label11" runat="server" BackColor="Transparent" BorderColor="Transparent"
BorderStyle="None" Font-Size="Medium" ForeColor="BlueViolet" Text="Email"></asp:Label>
<asp:TextBox ID="TextBoxemail" runat="server" Width="370px"></asp:TextBox>
<br />
<br />
<asp:Label ID="Label12" runat="server" BackColor="Transparent"
BorderColor="Transparent" BorderStyle="None" Font-Size="Medium" ForeColor="BlueViolet"
Text="Petition Summary"></asp:Label>
<asp:TextBox ID="TextBoxsummary" runat="server" Height="25px" Width="593px" TextMode="MultiLine"></asp:TextBox>
<br />
<br />
<asp:Button ID="Buttonadd" runat="server" Font-Bold="True" OnClick="Button1_Click"
Text="Submit Petition" Width="112px" BackColor="#FFFFC0" BorderColor="#FFFFC0" />
<asp:Button ID="Button1" runat="server" BackColor="#FFFFC0" BorderColor="#FFFFC0"
Font-Bold="True" PostBackUrl="~/Default.aspx" Text="Home" />
<br />
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:jantadarbarnwdConnectionString8 %>"
DeleteCommand="DELETE FROM [Table1] WHERE [id] = @id" InsertCommand="INSERT INTO [Table1] ([fullname], [Gender], [Address1], [Address2], [Address3], [Block], [Panchayat], [Village], [Phone_Mobile], [Email], [Petition_summary]) VALUES (@fullname, @Gender, @Address1, @Address2, @Address3, @Block, @Panchayat, @Village, @Phone_Mobile, @Email, @Petition_summary)"
SelectCommand="SELECT * FROM [Table1]" UpdateCommand="UPDATE [Table1] SET [fullname] = @fullname, [Gender] = @Gender, [Address1] = @Address1, [Address2] = @Address2, [Address3] = @Address3, [Block] = @Block, [Panchayat] = @Panchayat, [Village] = @Village, [Phone_Mobile] = @Phone_Mobile, [Email] = @Email, [Petition_summary] = @Petition_summary WHERE [id] = @id">
<DeleteParameters>
<asp:Parameter Name="id" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="fullname" Type="String" />
<asp:Parameter Name="Gender" Type="String" />
<asp:Parameter Name="Address1" Type="String" />
<asp:Parameter Name="Address2" Type="String" />
<asp:Parameter Name="Address3" Type="String" />
<asp:Parameter Name="Block" Type="String" />
<asp:Parameter Name="Panchayat" Type="String" />
<asp:Parameter Name="Village" Type="String" />
<asp:Parameter Name="Phone_Mobile" Type="String" />
<asp:Parameter Name="Email" Type="String" />
<asp:Parameter Name="Petition_summary" Type="String" />
<asp:Parameter Name="id" Type="Int32" />
</UpdateParameters>
<InsertParameters>
<asp:controlParameter ControlID="textboxfullname" PropertyName="text" Name="fullname" Type="String" />
<asp:controlParameter ControlID="textboxgender" PropertyName="text" Name="Gender" Type="String" />
<asp:controlParameter ControlID="textboxadd1" PropertyName="text" Name="Address1" Type="String" />
<asp:controlParameter ControlID="textboxadd2" PropertyName="text" Name="Address2" Type="String" />
<asp:controlParameter ControlID="textboxadd3" PropertyName="text" Name="Address3" Type="String" />
<asp:controlParameter ControlID="DropDownList1" PropertyName="text" Name="Block" Type="String" />
<asp:controlParameter ControlID="textboxpanchayat" PropertyName="text" Name="Panchayat" Type="String" />
<asp:controlParameter ControlID="textboxvillage" PropertyName="text" Name="Village" Type="String" />
<asp:controlParameter ControlID="TextBoxphone_mobile" PropertyName="text" Name="Phone_Mobile" Type="String" />
<asp:controlParameter ControlID="textboxemail" PropertyName="text" Name="Email" Type="String" />
<asp:controlParameter ControlID="TextBoxsummary" PropertyName="text" Name="Petition_summary" Type="String" />
</InsertParameters>
</asp:SqlDataSource>
<br />
<br />
<br />
<br />
<br />
<br />
</div>
</form>
</body>
</html>
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Thursday, February 9, 2012 1:13 AM
All replies
-
User803630265 posted
u see this image below and than see video on you tube step by step part 2 to 4 and solve ur problem
http://www.youtube.com/watch?v=D6qf3UcT0Xk&feature=related ok thanks
Tuesday, February 7, 2012 6:32 AM -
User3866881 posted
Hello MengYao:)
1)Please make sure that your access's datatable is designed correctly,with a primary key。
2)Then Use AccessDataSource to generate CRUD。
3)Bind the AccessDataSource to the GridView。
See this torturial:http://quickstarts.asp.net/QuickStartv20/aspnet/doc/data/databases.aspx#updatedelete
Wednesday, February 8, 2012 8:35 PM -
User803630265 posted
u use this code
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Petent.aspx.cs" Inherits="Petent" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div style="table-layout: auto; background-color: #ccff66">
<br />
<br />
<br />
<br />
<asp:Label ID="Label1" runat="server" BackColor="Transparent" BorderColor="Transparent" Font-Bold="True" Font-Italic="True" Font-Names="Gautami"
Font-Size="XX-Large" Font-Strikeout="False" Font-Underline="True" ForeColor="BlueViolet"
Height="49px" Text="Nawada Public Grievance Redressal System" Width="608px"></asp:Label>
<br />
<br />
<br />
<br />
<asp:Label ID="Label2" runat="server" BackColor="Transparent"
BorderColor="Transparent" BorderStyle="None" Font-Size="Medium" ForeColor="BlueViolet"
Text="Full Name"></asp:Label>
<asp:TextBox ID="TextBoxFullname" runat="server" Font-Size="Medium" Width="186px"></asp:TextBox>
<asp:Label ID="Label3" runat="server" BackColor="Transparent" BorderColor="Transparent" BorderStyle="None"
Font-Size="Medium" ForeColor="BlueViolet" Text="Gender"></asp:Label>
<asp:TextBox ID="TextBoxgender" runat="server" Width="43px"></asp:TextBox>
<asp:Label ID="Label4" runat="server" BackColor="Transparent" BorderColor="Transparent" BorderStyle="None"
Font-Size="Medium" ForeColor="BlueViolet" Text="Address1"></asp:Label>
<asp:TextBox ID="TextBoxadd1" runat="server" Width="162px"></asp:TextBox><br />
<br />
<asp:Label ID="Label5" runat="server" BackColor="Transparent" BorderColor="Transparent" BorderStyle="None"
Font-Size="Medium" ForeColor="BlueViolet" Text="Address2" Width="71px"></asp:Label>
<asp:TextBox ID="TextBoxadd2" runat="server" Width="185px"></asp:TextBox>
<asp:Label ID="Label6" runat="server" BackColor="Transparent"
BorderColor="Transparent" BorderStyle="None" Font-Size="Medium" ForeColor="BlueViolet"
Text="Address3"></asp:Label>
<asp:TextBox ID="TextBoxadd3" runat="server" Width="302px"></asp:TextBox>
<br />
<br />
<asp:Label ID="Label7" runat="server" BackColor="Transparent"
BorderColor="Transparent" BorderStyle="None" Font-Size="Medium" ForeColor="BlueViolet"
Text="Block" Width="55px"></asp:Label>
<asp:DropDownList ID="DropDownList1" runat="server"
AutoPostBack="True" DataSourceID="SqlDataSource1" DataTextField="block"
DataValueField="block">
</asp:DropDownList>
<asp:Label ID="Label8" runat="server" BackColor="Transparent"
BorderColor="Transparent" BorderStyle="None" Font-Size="Medium" ForeColor="BlueViolet"
Text="Panchayat"></asp:Label>
<asp:TextBox ID="TextBoxpanchayat" runat="server"></asp:TextBox>
<asp:Label ID="Label9" runat="server" BackColor="Transparent" BorderColor="Transparent" BorderStyle="None"
Font-Size="Medium" ForeColor="BlueViolet" Text="Village"></asp:Label>
<asp:TextBox ID="TextBoxvillage" runat="server" Width="162px"></asp:TextBox>
<br />
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:jantadarbarnwdConnectionString7 %>"
SelectCommand="SELECT [block] FROM [block]"></asp:SqlDataSource>
<br />
<asp:Label ID="Label10" runat="server" BackColor="Transparent"
BorderColor="Transparent" BorderStyle="None" Font-Size="Medium" ForeColor="BlueViolet"
Text="Phone/Mobile"></asp:Label> <asp:TextBox ID="TextBoxphone_mobile"
runat="server" OnTextChanged="TextBoxphone_mobile_TextChanged"></asp:TextBox>
<asp:Label ID="Label11" runat="server" BackColor="Transparent" BorderColor="Transparent"
BorderStyle="None" Font-Size="Medium" ForeColor="BlueViolet" Text="Email"></asp:Label>
<asp:TextBox ID="TextBoxemail" runat="server" Width="370px"></asp:TextBox>
<br />
<br />
<asp:Label ID="Label12" runat="server" BackColor="Transparent"
BorderColor="Transparent" BorderStyle="None" Font-Size="Medium" ForeColor="BlueViolet"
Text="Petition Summary"></asp:Label>
<asp:TextBox ID="TextBoxsummary" runat="server" Height="25px" Width="593px" TextMode="MultiLine"></asp:TextBox>
<br />
<br />
<asp:Button ID="Buttonadd" runat="server" Font-Bold="True" OnClick="Button1_Click"
Text="Submit Petition" Width="112px" BackColor="#FFFFC0" BorderColor="#FFFFC0" />
<asp:Button ID="Button1" runat="server" BackColor="#FFFFC0" BorderColor="#FFFFC0"
Font-Bold="True" PostBackUrl="~/Default.aspx" Text="Home" />
<br />
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:jantadarbarnwdConnectionString8 %>"
DeleteCommand="DELETE FROM [Table1] WHERE [id] = @id" InsertCommand="INSERT INTO [Table1] ([fullname], [Gender], [Address1], [Address2], [Address3], [Block], [Panchayat], [Village], [Phone_Mobile], [Email], [Petition_summary]) VALUES (@fullname, @Gender, @Address1, @Address2, @Address3, @Block, @Panchayat, @Village, @Phone_Mobile, @Email, @Petition_summary)"
SelectCommand="SELECT * FROM [Table1]" UpdateCommand="UPDATE [Table1] SET [fullname] = @fullname, [Gender] = @Gender, [Address1] = @Address1, [Address2] = @Address2, [Address3] = @Address3, [Block] = @Block, [Panchayat] = @Panchayat, [Village] = @Village, [Phone_Mobile] = @Phone_Mobile, [Email] = @Email, [Petition_summary] = @Petition_summary WHERE [id] = @id">
<DeleteParameters>
<asp:Parameter Name="id" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="fullname" Type="String" />
<asp:Parameter Name="Gender" Type="String" />
<asp:Parameter Name="Address1" Type="String" />
<asp:Parameter Name="Address2" Type="String" />
<asp:Parameter Name="Address3" Type="String" />
<asp:Parameter Name="Block" Type="String" />
<asp:Parameter Name="Panchayat" Type="String" />
<asp:Parameter Name="Village" Type="String" />
<asp:Parameter Name="Phone_Mobile" Type="String" />
<asp:Parameter Name="Email" Type="String" />
<asp:Parameter Name="Petition_summary" Type="String" />
<asp:Parameter Name="id" Type="Int32" />
</UpdateParameters>
<InsertParameters>
<asp:controlParameter ControlID="textboxfullname" PropertyName="text" Name="fullname" Type="String" />
<asp:controlParameter ControlID="textboxgender" PropertyName="text" Name="Gender" Type="String" />
<asp:controlParameter ControlID="textboxadd1" PropertyName="text" Name="Address1" Type="String" />
<asp:controlParameter ControlID="textboxadd2" PropertyName="text" Name="Address2" Type="String" />
<asp:controlParameter ControlID="textboxadd3" PropertyName="text" Name="Address3" Type="String" />
<asp:controlParameter ControlID="DropDownList1" PropertyName="text" Name="Block" Type="String" />
<asp:controlParameter ControlID="textboxpanchayat" PropertyName="text" Name="Panchayat" Type="String" />
<asp:controlParameter ControlID="textboxvillage" PropertyName="text" Name="Village" Type="String" />
<asp:controlParameter ControlID="TextBoxphone_mobile" PropertyName="text" Name="Phone_Mobile" Type="String" />
<asp:controlParameter ControlID="textboxemail" PropertyName="text" Name="Email" Type="String" />
<asp:controlParameter ControlID="TextBoxsummary" PropertyName="text" Name="Petition_summary" Type="String" />
</InsertParameters>
</asp:SqlDataSource>
<br />
<br />
<br />
<br />
<br />
<br />
</div>
</form>
</body>
</html>
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Thursday, February 9, 2012 1:13 AM