Click here to Skip to main content
12,447,096 members (52,316 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# ASP.NET Gridview
Hi i am using 3-tier archtecture...i wnt row deleting button click event under gridview control ...any one could u plz help me solving my problem...
Posted 22-Nov-13 18:02pm
v2
Comments
karthik mahalingam01 23-Nov-13 0:44am
   
post some piece of code for references...
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

protected void ImageButton8_Click(object sender, ImageClickEventArgs e)
 {
     try
     {
         using (GridViewRow row = (GridViewRow)((ImageButton)sender).Parent.Parent)
         {
             HiddenField HidUseId = (HiddenField)row.FindControl("HiddenField1");
           
             {
 

             obj.User_Id =int.Parse(HidUseId.Value);
             obj.Value = 80;//check is it available or not
             dr = obj.CheckDummy();
             if (dr.HasRows)
             {
                 dr.Close();
               
 
                 obj.User_Id = int.Parse(HidUseId.Value);
                 obj.Value = 52; //delete query is here
                 obj.Delete();
 
                 ShowAlertMessage("Customer Details Deleted Sucessfully!...");
 
             }
             else
             {
                 dr.Close();
                 ShowAlertMessage("Failed!...");
             }
         
             }
             BindGrid1();
         }
     }
     catch (Exception ex)
     {
         lblstatus.Text = "Error" + ex.ToString();
     }
 }
  Permalink  
Comments
SrikanthChowdary 23-Nov-13 1:13am
   
Thank u for refering me.. it is helpful but i cont understand ...so please c my DB...delete the one perticular gridview row ...using delete button in 3-tier architecture..
USE [sample]
GO

/****** Object: Table [dbo].[newuserpat] Script Date: 11/23/2013 11:37:51 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[hello](
[ID] [int] IDENTITY(1,1) NOT NULL,
[LastName] [nvarchar](50) NULL,
[FirstName] [nvarchar](50) NULL,
[Title] [nvarchar](50) NULL,
[PracticeName] [nvarchar](50) NULL,
[PracticeAddress] [nvarchar](100) NULL,
[City] [nvarchar](50) NULL,
[State] [nvarchar](50) NULL,
[Zip] [nvarchar](50) NULL,
[Email] [nvarchar](50) NULL,
[Fax] [nvarchar](50) NULL,

CONSTRAINT [PK_newuserpat] PRIMARY KEY CLUSTERED
(
[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

-------------------------------------------

SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[hai](
[ID] [int] IDENTITY(1,1) NOT NULL,
[docpath] [nvarchar](100) NULL,
[docname] [nvarchar](50) NULL
) ON [PRIMARY]

GO
-------------------------
this is my DB . how did you write this i am Confusing with above code..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160811.3 | Last Updated 23 Nov 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100