Grid view delete command

To delete data from Oracle db table using Grid view controls

Page 1 of 1

5 Replies - 12544 Views - Last Post: 14 December 2011 - 09:27 AM Rate Topic: -----

#1 Soniyo  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 05-December 09

Grid view delete command

Post icon  Posted 29 December 2009 - 08:16 AM

Hello im making a project on online shopping so i hve dispalyed the products selected by customer in grid view and want to add delete the row when click on delete button. want to dispaly in grid view the product id and delete button depending upon the items in table say. "cart", I have written the code bt on clicking on delete button its generating illegal name/number error.
I have table "CART" with id as varchar datatype
<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" Title="Untitled Page" Debug ="true" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
	<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" Width="222px"  DataKeyNames ="id">

	<Columns>
		<asp:CommandField ShowDeleteButton="True" />
	<asp:boundfield headertext="Code"
			datafield="id" />
</Columns>
	</asp:GridView>
	
	<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
		ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" SelectCommand="SELECT id FROM CART" DeleteCommand="delete from CART where id =@id">   
		<DeleteParameters>
		</DeleteParameters>
		</asp:SqlDataSource>
		
</asp:Content>


pls help its urgent, im also trying on the same, thanks in advance

Is This A Good Question/Topic? 0
  • +

Replies To: Grid view delete command

#2 ramesh866  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 91
  • Joined: 03-October 09

Re: Grid view delete command

Posted 29 December 2009 - 10:00 AM

you can use this type
string s = ConfigurationManager.ConnectionStrings["masterConnectionString"].ConnectionString;
SqlConnection cn = new SqlConnection(s);
cn.Open();
SqlCommand cmd = new SqlCommand("delete from categorytable where CategoryId ='"+TextBox1.Text+"' ", cn);


cmd.ExecuteNonQuery();

GridView1.DataBind();
Was This Post Helpful? 0
  • +
  • -

#3 Soniyo  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 05-December 09

Re: Grid view delete command

Posted 29 December 2009 - 10:43 AM

Sorry sir, id idnt get it. coz im using oracle database and also dere is no text box on my web page,
I have placed grid view in web page and dan used sqldatasource to connect to oracle db and did the connection, so the data is displaying directly on grid view and clicking on delete button. And also above code where i should execute it,

pls help
Was This Post Helpful? 0
  • +
  • -

#4 ramesh866  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 91
  • Joined: 03-October 09

Re: Grid view delete command

Posted 29 December 2009 - 12:20 PM

ya that code should come in the delete button click event.. but you are using oracle,,, am well versed in sql.... refer these sites.. sure it will be of some help

http://bytes.com/top...-delete-command

http://www.experts-e...Q_24138194.html

This post has been edited by ramesh866: 29 December 2009 - 12:42 PM

Was This Post Helpful? 0
  • +
  • -

#5 Soniyo  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 05-December 09

Re: Grid view delete command

Posted 01 January 2010 - 12:13 PM

Thanyou for ur help

Bt i got its solution.
Was This Post Helpful? 0
  • +
  • -

#6 swainsarada  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 14-December 11

Re: Grid view delete command

Posted 14 December 2011 - 09:27 AM

View PostSoniyo, on 01 January 2010 - 12:13 PM, said:

Thanyou for ur help

Bt i got its solution.



I have similar requirement.I am also getting same error after trying that code.Please share the solution with me.

Thanks in advance.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1