.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan
Post New Web Links

Gridview Delete not working

Posted By:      Posted Date: September 13, 2010    Points: 0   Category :WCF
 
I just downloaded VS2010 with Framework 4.0.30319 I've bound a gridview control to a datasource, defined the select, insert, and delete SQL statements. Select and insert are working just fine thank you, but when I select the (auto-generated) Delete link, a postback occurs, but the row/record remains in the gridview. I have the one-segment key in the select statement, in an invisible column of the gidview. I've set the DataKeyNames property to this column name (CinID).  The delete query reads - DELETE FROM CallIn WHERE (CinID = Cid) I've defined the parameter Cid as the Gridview.SelectedRow, .SelectedDataKey, .SelectedIndex, and .SelectedValue, all with no joy. I created SUB Gridview.RowCommand put a breakpoint there. e.Command shows "Delete" and e.CommandArgument shows the correct row index (1). I created SUB Girdview.DeletingRow and put a breakpoint there. debug shows .SelectedRow=nothing and .SelectedDataKey=nothing (but I don't know if they *should* show something, since I'm not selecting, but rather deleting the row. The postback occurs (click), the grid refreshes, but nothing happens. I cannot figure out why the clicked-on row does not delete. Any ideas?  


View Complete Post


More Related Resource Links

The delete and edit buttons not working in gridview!

  
Hi everyone. I have problem with the buttons Edit and Delete in Gridview for very long time and i really need help about it.  So the when i click edit i get in edit mode and when click update the values in the row i was changing disappear but only in the gridview. When check in the Database nothing happens. The delete button not works at all, i mean when click on it only refresh the table. If see something wrong in my code please help. See how looks my page:Now here's my code in aspx:<%@ Page Language="C#" Title="Specific Search in Phone Directory" ... ... ... <asp:SqlDataSource ID="SqlDataSource7" runat="server" ConnectionString="<%$ ConnectionStrings:ThisIsMyConnection2 %>" OldValuesParameterFormatString="original_{0}" DeleteCommand="DELETE FROM [Resident] WHERE [MobileNum] = @MobileNum" InsertCommand="INSERT INTO [Resident] ([FNAME], [LNAME], [MobileNum], [HomeNum], [OfficeNum], [FaxNum]) VALUES (@FNAME, @LNAME, @MobileNum, @HomeNum, @OfficeNum, @FaxNum)" SelectCommand = "SELECT * FROM [Resident] WHERE (([FNAME] + ' ' + [LNAME] LIKE '%' + @FANDLNAME + '%'))" UpdateCommand=

Gridview Delete not working

  

I just downloaded VS2010 with Framework 4.0.30319

I've bound a gridview control to a datasource, defined the select, insert, and delete SQL statements. Select and insert are working just fine thank you, but when I select the (auto-generated) Delete link, a postback occurs, but the row/record remains in the gridview.

I have the one-segment key in the select statement, in an invisible column of the gidview. I've set the DataKeyNames property to this column name (CinID).  The delete query reads -

DELETE FROM CallIn WHERE (CinID = Cid)

I've defined the parameter Cid as the Gridview.SelectedRow, .SelectedDataKey, .SelectedIndex, and .SelectedValue, all with no joy. I created SUB Gridview.RowCommand put a breakpoint there. e.Command shows "Delete" and e.CommandArgument shows the correct row index (1). I created SUB Girdview.DeletingRow and put a breakpoint there. debug shows .SelectedRow=nothing and .SelectedDataKey=nothing (but I don't know if they *should* show something, since I'm not selecting, but rather deleting the row.

The postback occurs (click), the grid refreshes, but nothing happens. I cannot figure out why the clicked-on row does not delete. Any ideas?

It has been suggested that I explicitly set the .Selecte

Adding Dynamic Rows in ASP.NET GridView Control with TextBoxes and with Delete functionality

  
In my previous examples, I have demonstrated on how to add dynamic rows in GridView control with TextBoxes and how to save the values into the database. Now, seems that most of the developers are asking if how to add a delete functionality with it. So in this example, I'm going to show on how to delete a certain row in the dynamic GridView with TextBoxes.

update/delete not working on server only

  

my aspx page works in VWD, and everything works on the server EXCEPT update and delete sql functions. any ideas?

thanks 


Add, Edit, update, Delete gridview

  
The article Add, Edit, update, Delete gridview was added by anjankant on Friday, July 09, 2010.

Thousandas operation we can do on Gridview control. Here I as explaining how we can add new recored and edit of existing record and delete a record in Gridview. Step1 : You can add this gridview in your aspx form. Here some events of Gridview are fired

Disable check box in a gridview does not working

  

Hi

I have a check box in a template field in a gridview.

Based on some condition, I want those check boxs to  be enable and disable.

I am trying the below code but does working..

 protected void GVstudents_RowDataBound(object sender, GridViewRowEventArgs e)
        {
              if (e.Row.RowType == DataControlRowType.DataRow)
                {
                    
                    string studentID = GVstudents.DataKeys[0].Value.ToString();
                    int stdID = Convert.ToInt32(studentID);
                    int schID = profile.getSchoolIDByStudentID(stdID);
                    int tchrID = profile.getTeacherIDByStudentID(stdID);

                    if (patti.chkIsTeacherPaid(stdID, schID, tchrID))
                    {
                        CheckBox cb = (CheckBox)e.Row.FindControl("chkTeacherPayment");
                        cb.Enabled = false;
                        cb.Checked = true;
                    }
                   

                 }
            
        }

any help??


Gridview check all not working in Mozila Firefox

  

hi all,

i has an gridview first column header is Checkbox, when i click on that all the detail column checkboxes were selected if i use IE but the same not working in Mozila Firefox

below is my code

function checkAll()
              {
                  var totalChkBoxes = parseInt('<%= gv5.Rows.Count %>');
                  var gvControl = document.getElementById('<%= gv5.ClientID %>');
                  var gvChkBoxControl = "cbCheckProd";
                  var mainChkBox = document.getElementById("chkBoxAll");
                  var inputTypes = gvControl.getElementsByTagName("input");
                  for (var i = 0; i < inputTypes.length; i++)
      &

Delete not working on List.aspx - out of box

  

Hello,


I'am trying to use Dynamic data web site on my project. I have Visual Studio 2010 enf Framework 4.0. I create the default project with the wizard. I add my own Entity Data Model.

When I try to use the "delete" autogenerated button on List.aspx, on the table ServerSetting (see image below), I receive a null exception.  I have no custom code involved in this operation and cannot seem to determine what is Null.

Any help would be appreciated!



Thanks,




Ben

[NullReferenceException: Object reference not set to an instance of an object.]
   System.Data.Objects.Internal.ForeignKeyFactory.CreateConceptualNullKey(EntityKey originalKey) +30
   System.Data.Objects.DataClasses.EntityReference.NullAllForeignKeys() +722
   System.Data.Objects.EntityEntry.NullAllForeignKeys() +235
   System.Data.Objects.EntityEntry.Delete(Boolean doFixup) +77
   System.Data.Objects.EntityEntry.Delete() +9
   System.Data.Objects.ObjectContext.DeleteObject(Object entity, EntitySet expectedEntitySet) +169
   System.Data.Objects.ObjectContext.DeleteObject

Dynamically creating Gridview Template - Linkbutton Click not working

  

Hi, 

I have written some code to dynamically generate template columns for gridview which works well. However, each cell in the gridview has to be a linkbutton, which when clicked does a db update and redirects to a specific url with some parameters in it.

I have attached a click event handler to the linkbutton in the InstantiateIn method but the event does not seem to fire.

Could someone please help? the code is below -

//Dynamically creating the Grid


protected void btnAnalyze_Click(object sender, EventArgs e)
    {
       
            gvProjectedCPM.Columns.Clear();

Edin, New and Delete buttons in gridview?

  

Hi guys. I have gried view that shows me all info from the table i made. So my SelectCommand works fine. I'v add 3 additional buttons "new", "edit" and "delete" i'v made their query but still have mistake by clicking it in browser. I follow from the book Begginer to Novice 3.5 ASP C# but that's what it's shown. I know something missing. I'v check in the net but not found how to fixed, because i use SqlDataSource. Can you advise how to proceed from here? Here's what i did:


<asp:SqlDataSource ID="SqlDataSource5" runat="server" ProviderName="System.Data.SqlClient" ConnectionString="<%$ ConnectionStrings:ThisIsMyConnection%>"

 

              SelectCommand = "SELECT * FROM [Resident] WHERE (([FNAME] + ' ' + [LNAME] LIKE '%' + @FANDLNAME + '%'))"

 

              UpdateCommand = "UPDATE Resident SET FNAME=@FNAME, LNAME=@LNAME, MobileNum=@MobileNum, HomeNum=@HomeNum, OfficeNum=@OfficeNum, FaxNum=@FaxNum WHERE FNAME=@original_FNAME AND LNA

Delete from gridview

  
I have read about 20 articles and I can't figure out what I have done wrong.  I am trying to delete from a gridview.  Below is the code.  Any help is appreciated. <form runat='server'> <asp:SqlDataSource  ID='dsTest'  Runat='server'  ConnectionString="<%$ ConnectionStrings:myCnn %>"  SelectCommand="SELECT [ID], [Name], [Enabled], [FavoriteColor] FROM tblTest"  UpdateCommand="UPDATE tblTest SET [Name] = @Name, [Enabled] = @Enabled, [FavoriteColor] = @FavoriteColor WHERE ID = @ID"  DeleteCommand="DELETE FROM tblTest WHERE ID = @ID">  <DeleteParameters>   <asp:Parameter    name="ID" />  </DeleteParameters> </asp:SqlDataSource> <asp:GridView  ID="gvTest"  Runat='server'  DataKeyNames='ID'  AutoGenerateColumns='true'  AutoGenerateEditButton='true'  AutoGenerateDeleteButton='true'  DataSourceID="dsTest" /></form>Exception Details: System.Data.SqlClient.SqlException: Must declare the variable '@ID'.

Delete not working all the time.

  
From time to time i am getting this error when attempting to delete a file. Exception Details: System.IO.IOException: The process cannot access the file 'D:\gallery\images\Untitled-1.jpg' because it is being used by another process. And the times i see it most is if i upload the image and then within seconds try to delete the image. Is there anything that can be done on my part to help prevent this? 

Problem with "Edit" and "Delete" buttons in gridview!

  
Hi everyone. I have problem with the buttons Edit and Delete in Gridview for very long time and i really need help about it. So i have gridview and sqldatasource. First i try to make this buttons manually and as you will see in sqldatasource 5 and 6 i have these buttons my records show up but the buttons not working. After that i was advised to do it automatically with gridview smart tag options and Generate columns - this is what i did in sqldatasource7 and gridview7. But both ways i need to change the statements with my own because that what they create not works. So select statement works. Now the error that i get in both ways is the same:The GridView 'GridView(the number could be 5,6 or 7)' fired event RowEditing which wasn't handled.See how looks my page:Now here's my code in aspx:<%@ Page Language="C#" Title="Specific Search in Phone Directory" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="serv

Can not set delete up at GridView

  
Hello:I am trying to add delete, update function to the gridview.After set up sqldatasource, configure the select statement, click next, it showed: test query, then finish.I did not get Advanced SQL generation Optionson the Configure the select statement, there is Advanced button at the right side. However, I clicked, it showed: Advanced SQL Generation Options, but it is disabled.How to enable Advanced SQL Generation Options so that I could set up delete, update etc functions.I am usingMicrosoft visual studio 2005Versioin 8.0.50727.762 (SP.050727-7600)Your help is highly appreciated.

Attempting to use an HTTP handler to display pictures in gridview. It's not working, please help.

  
I am writing a web page that needs pictures displayed for each item.  The page works just fine except for the pictures.  I have a file called handler.ashx uploaded to the server as well.  It does not seem to be hurting anything, but it doesn't seem to help display the pictures either!  I am working with a MySQL database so I am thinking that the call for the data or the ashx page's structure itself are my problem.  I am using C# Express so there is no generic handler class to autoload and therefore my handler page is pasted together and I know the using statements are in the wrong place, but I'm new to this and I'm lost!  The following is my database table info (table is named: Yamaha), my handler.ashx page code, and the code for the final web page.  I have loaded ".jpeg" or "jpeg" into the field I added called "Image_Type"  since I have already uploaded all pictures as longblobs.  You can view the final web page here: http://www.88867honda.com/YamahaPtsSale.aspx Thanks in advance for any help, Melissa   Table info: Field TypeAttributes--> Null DefaultExtra--> Comments part_number varchar(15)  --> No     -->   description varchar(50)  --> Yes  NULL   -->   qty int(4)  --> Yes  NULL  

Gridview and delete option - Button click displays message

  
Hi, I have a gridview connected to a sql database that allows the user to delete the record. I used the ASP.net automatic "options" for this. However, I would like when the user deletes a record, a message (textbox) appears in the form to say the record has been deleted. Please can anyone provide some sample codes?   Thanks in advance. Nijojo.

Gridview rowupdated not working

  
hi frienz,After i click edit, i will get Update and Cancel button When I viewsource, I get this <input type="submit" name="GridView1$ctl07$ctl01" value="Update" onclick="javascript:WebForm_DoPostBackWithOptions( new WebForm_PostBackOptions(&quot;GridView1$ctl07$ctl0 1&quot;, &quot;&quot;, true, &quot;&quot;, &quot;&quot;, false, false))" / >&nbsp;<input type="button" value="Cancel" onclick="javascript:__doPostBack('GridView1','Canc el$5')" Cancel Works. But Update doesnt. Why? perhaps WebForm_DoPostBackWithOptions is not constructed properly. A Bug? Perhaps. So when I manually execute "__doPostBack('GridView1','Update $5')", it will call RowUpdating. Weird ! Why does this happen? but onRowupdating event not fired anybody can suggest methank u
Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend