Delete Data From Gridview Which Is Using Datasource And SP Using Wizard

Mar 2, 2010

I am using a gridview to select, delete and update data in database. I have written a single SP for doing all these operation. Based on a parameter SP decides which operation to perform. Here is the image of my gridview

<asp:GridView ID="GridView1" runat="server" DataSourceID="dsDomain"
AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False"
DataKeyNames="DomainId" >
<Columns>
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
<asp:BoundField DataField="DomainId" HeaderText="DomainId"
InsertVisible="False" ReadOnly="True" SortExpression="DomainId">
</asp:BoundField>
<asp:BoundField DataField="Domain" HeaderText="Domain"
SortExpression="Domain">
</asp:BoundField>
<asp:BoundField DataField="Description" HeaderText="Description"
SortExpression="Description" >
</asp:BoundField>
<asp:BoundField DataField="InsertionDate" HeaderText="InsertionDate"
SortExpression="InsertionDate">
</asp:BoundField>
</asp:GridView>
Data Source that I am using is here
<asp:SqlDataSource ID="dsDomain" runat="server"
ConnectionString="<%$ ConnectionStrings:conLogin %>"
SelectCommand="Tags.spOnlineTest_Domain"
SelectCommandType="StoredProcedure" CancelSelectOnNullParameter="False"
DeleteCommand="Tags.spOnlineTest_Domain" DeleteCommandType="StoredProcedure" OnDeleting="DomainDeleting">
<SelectParameters>
<asp:Parameter ConvertEmptyStringToNull="true" DefaultValue="" Name="DomainId" Type="String" />
<asp:Parameter ConvertEmptyStringToNull="true" DefaultValue="" Name="Domain" Type="String" />
<asp:Parameter ConvertEmptyStringToNull="true" DefaultValue="" Name="Description" Type="String" />
<asp:Parameter DefaultValue="1" Name="OperationType" Type="Byte" />
</SelectParameters>
<DeleteParameters>
<asp:ControlParameter ControlID="GridView1" Name="DomainId"
PropertyName="SelectedValue" Size="4" Type="Int32" />

Select operation is working fine. But when I tried to delete, it says Procedure or Function 'spOnlineTest_Domain' expects parameter '@Domain', which was not supplied But I am supplying this parameter, as My Stored procedure calling is like this

EXEC Tags.spOnlineTest_Domain NULL, NULL, NULL, 1 // For Select last parameter will be 1
EXEC Tags.spOnlineTest_Domain "SelectedRow's DomainId), NULL, NULL, 4 // For Delete last parameter will be 4

My procedure has 4 parameters where last parameter will be set by programmer which will tell the program for what kind of operation to be performed. For Select only last parameter has to be Not Null. For Delete first and last parameter cannot be NULL. My first Delete parameter is Primary key of the table. I am passing this value, when a user selects a row and hit delete. I am not sure by using PropertyName="SelectedValue", will I get the right value of the ID.

View 1 Replies


Similar Messages:

DataSource Controls :: Tableadapter Configuration Wizard Cannot Generate The Delete&update Statement

May 4, 2010

in generate the Stored Procedures when using Create TableAdapter configuration Wizard in VS.it can not generate the Stored Procedures for Delete and Update Commands, but it generated for Select and Insert. i tried many times, but still get the same problem.

View 2 Replies

DataSource Controls :: Update / Insert And Delete SQL Statements For Define Custom Statements Wizard

Feb 23, 2011

I'm using the 'Configure Data Source' wizard to connect to my database and show the dataset in Gridview. I want to be able to update, insert and delete entries but am unsure how to build the query. I can write simple update statments to change database entries but how can I do this for entries that have been changed within the gridview?

View 6 Replies

Forms Data Controls :: Deleting From GridView Without Call Datasource's Delete Command

Jan 21, 2010

I'm using the asp.net membership on my website. On the User Administration page i've got a GridView to show the details of the users on the site. As a datasource rather than just using the Membership.GetAllUsers function i've got a SQLDataSource as i need to display user information from 3 different tables. I'm trying to add a delete button to the GridView. I'm setting the Membership's UserName as a DataKey and then using the RowDeleting event to call Membership.DeleteUser for the appropriate UserName. This works fine and the user is deleted however i then get an error showing up that "Deleting is not supported by data source 'SqlDataSource1' unless DeleteCommand is specified."

I don't want to use the SqlDataSource for deleting as i've already done it using the Membership. How can i stop it from trying to do this? Here is the cut-down that i have if you're interested. The selectcommand in the sqldatasource was auto-generated by it.

[Code]....

View 5 Replies

Forms Data Controls :: Datasource Update / Delete Queries For Gridview - Can't Edit

Dec 7, 2010

I have a gridview that pulls data from two tables, CLIENT and PAYMENT. I want to add the edit, delete functions to the gridview for the payment portion of the table, that is to edit or delete the payments but not the client. I've manually enabled the edit, delete functions and input the queries. I've also deleted the textboxes from the templates which draw from the CLIENT table so they cannot be edited. Everything looks good on the surface until I actually go to edit or delete anything, and it has no effect.Here's the structure of the two tables:

CLIENT PAYMENT
ClientID Pk PaymentNumber Pk
FName CLIENT$ClientID Fk
LName PaymentDate
ContactNo NULL PaymentAmount
ArrivalDate PaymentDetails NULL
DepartureDate NULL
CurrentResident

Here's the update query:

UPDATE [PAYMENT] SET [PaymentDate] = @PaymentDate, [PaymentAmount] = @PaymentAmount, [PaymentDetails] = @PaymentDetails WHERE [PaymentNumber] = @original_PaymentNumber AND [CLIENT$ClientID] = @original_CLIENT$ClientID AND [PaymentDate] = @original_PaymentDate
AND [PaymentAmount] = @original_PaymentAmount AND (([PaymentDetails] = @original_PaymentDetails) OR ([PaymentDetails] IS NULL AND @original_PaymentDetails IS NULL))

Finally, here's the delete query:

DELETE FROM [PAYMENT] WHERE [PaymentNumber] = @original_PaymentNumber AND [CLIENT$ClientID] = @original_CLIENT$ClientID AND [PaymentDate] = @original_PaymentDate AND [PaymentAmount] = @original_PaymentAmount AND (([PaymentDetails] = @original_PaymentDetails)
OR ([PaymentDetails] IS NULL AND @original_PaymentDetails IS NULL))

View 3 Replies

Forms Data Controls :: Delete Confirmation Box In Gridview With Edit And Delete Buttons?

Nov 18, 2010

How do I reference the delete button to add the delete confirmation box when I have both the Edit and Delete buttons as the last two columns in the Gridview control. The following code works fine without any issues when I have the delete button only:

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType != DataControlRowType.DataRow) return;
int lastCellIndex = e.Row.Cells.Count - 1;
Button db = (Button)e.Row.Cells[lastCellIndex].Controls[0];
db.OnClientClick = "if (!window.confirm('Are you sure you want to delete this record?')) return false;";
}

But, when I have both the Edit and the Delete buttons, I get the following error when I click the edit button while the delete button works fine.

Specified argument was out of the range of valid values. Parameter name: index

How do I reference the delete button so the edit button is not affected in this case?

View 4 Replies

Forms Data Controls :: Delete Images From Folder Using Gridview Delete Link?

Feb 3, 2010

Using "Enable Delete" from Gridview control, I can delete (besides, update, sort, paging, etc) data from the database (this is done automatically). However, how can I delete the actual image that resides in my image folder (i.e. from "pix" folder )? What is the best way to delete image? If using code behind, how? Please write a full code for me. Here is my source code.

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="photoID"

View 12 Replies

Forms Data Controls :: How To Insert Delete Confirmation Dialog To Gridview Delete Button

Apr 6, 2010

I am using Sharepoint Designer and trying to insert a Delete button into a gridview. I added this to the top of my ASPX:

<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls"
Assembly="Microsoft.SharePoint, Version=11.0.0.0, Culture=neutral,
PublicKeyToken=71e9bce111e9429c" %>

and I added this as a Gridview column:

<SharePoint:DeleteItemButton
runat="server"
ID="CustomFormDeleteItemButton"
ControlMode="Edit"
/>

and this is the error I get:

An error occurred during the processing of . System.Web.UI.WebControls.DataControlFieldCollection must have items of type 'System.Web.UI.WebControls.DataControlField'. 'SharePoint:DeleteItemButton' is of type 'Microsoft.SharePoint.WebControls.DeleteItemButton'.

View 4 Replies

DataSource Controls :: Whole Gridview Was Deleted When Trying To Delete Only 1 Row?

Jan 10, 2011

I am trying to delete a row of records in a gridview. The selectMethod works perfectly fine, but the DeleteMethod doesn't. When I delete a row, only 1 row of records should be deleted, but the whole gridview was deleted! (I have about 3 -5 rows of data). I am using ObjectDataSource.

Data Access Layer

[Code]....

Business Logic Layer

[Code]....

Presentation Layer

Design:

[Code]....

Presentation Layer

Code Behind:

[Code]....

View 6 Replies

DataSource Controls :: Delete Checkbox From Gridview?

Feb 18, 2011

I am trying to run a delete command from multiple tables and cant seem to get it to work. When you run the delete it just refreshes the gridview... Below is my delete command and parameters along with the code behind that I run.

DeleteCommand="DELETE FROM RecipeBox, Recipes WHERE (RecipeBox.ID = @RecipeID) or (Recipes.RecipeID = @RecipeID)">
<DeleteParameters>
<asp:Parameter Name="RecipeID" />

[Code]....

View 3 Replies

Forms Data Controls :: DataSource Config Wizard Not Working With DropDownList?

May 9, 2010

Stuck trying to populate a dropdownlist with an ObjectDataSource using the wizard.

using the wizard i can successfully configure the datasource, then I can choose the datasource. The next step you should be able to select your display value and the selected value. However, these boxes are not populated within the wizard. I added a gridview to test the datasource and it displays fine.

[Code]....

View 4 Replies

Way To Use VS 2005 Gridview Delete Button With Datasource Markup

Jul 24, 2010

using gridview delete button with datasource markup:
source Code:

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:direct_deliveryConnectionString %>"
SelectCommand="select pk_ddlvryDetailID,fk_grfdetailID,itemDescription,qty,uom,rate,(qty*rate) as Amount
from qddlvrydetails
where fk_ddlvryMasterID=@id"
DeleteCommand="delete
from tblddlvrydetails
where pk_ddlvrydetailid=@id">
[code]...
I created a parameter named @ID which will received value from grid selectedvalue whenever the delete button fire up but whenever i do that the will just postback without delete the row.

View 5 Replies

DataSource Controls :: Unable To Delete From Gridview With Commandname?

Feb 28, 2010

i have a gridview associated with a sqldatasource.the gridview contain a templateField column like this

[Code]....

however when i click on the templatefieldcolumn nothing happens (no delete)

View 4 Replies

DataSource Controls :: Can't DDS Package That's Have Been Save From SQL Server Data Import/Export Wizard

Feb 23, 2010

I have to export some data from excel to sql server. So, I just used simply Import/Export wizard from Management Studio.

Fill up and set the all necessary according to this wizard, after that I saved as SSIS Package.

Because, I have to run this package several time, but unfortunately, I can't find it where she saved it.

That may be funny, but really i can't find it out So, How to i save this package?

View 2 Replies

DataSource Controls :: Delete Gridview Records With Enable Deleting

Feb 19, 2010

I have bounded my GridView to an ObjectDataSource. I have set a delete method for this ObjectDataSource. Now how can I delete my GridView's records with enable Deleting?

View 4 Replies

Forms Data Controls :: Update Value Datetime In Gridview Wizard?

Jan 21, 2011

I use gridview and sqldatasource wizard for update value. If i need update some value example close_date (datetime value) only. What should i do?

[Code]....

View 2 Replies

Forms Data Controls :: Unable To Validate GridView Items In Wizard Control?

Mar 18, 2010

I'm trying to validate that a GridView logated in one of the steps of the Wizard Control is populated by the user before the Next button is clicked. What I mean is that I need to block Next (or Prev) button until the user populates a gridview, once the gridview has at least one element then enable the (Next/Prev) buttons. How can I enable/disable Next/Prev buttons within a specific step?.

View 1 Replies

Forms Data Controls :: Delete Row From ListView With No DataSource?

Apr 28, 2010

First time using a ListView control, I have it inside an UpdatePanel:

[Code]....

[Code]....

[Code]....

[Code]....

When the UpdatePanel Loads, it feeds the data to the ListView. Whenever the user clicks on a row in the ListView, a new window displaying a "note" pops up, the ItemDataBound event ties it all together. What I'm trying to do is add a button to each row so that the user can delete the row. This would call a Sql statement and then the row should disappear. I followed a couple of articles I found on ListView on how to do this, so I added a button called imgBtnDeleteNote (see markup above) and set the CommandName = "Delete", hoping that it would trigger the ItemCommand and ItemDeleting event (I have some bogus code in them, first I wanted to see if they would trigger).

The problem is that they don't seem to get triggered when I click on the delete button. All the rows in the listview disappear, and when I manually refresh the page they come back. My guess is that the events are not firing because I'm not using a DataSource object in the aspx code, but I'm not sure.

View 5 Replies

DataSource Controls :: Unable To Delete Data In The Third Table.

Mar 18, 2010

I have three tables:

Colour(Colour ID, Colour)
DogColours(ColourID, Dog ID)
Dog(Dog ID, Breed)

Colour ID and Dog are primary keys.

I have three web forms, one for each table. Dog colours consists of data that is already in the system from the other two tables. It basically joins a breed to a colour. My problem is this:

When i try delete a dog which is being used in dog colours the program crashes. How can i prevent this crash?

The second problem, the data source in the dog colours web form has the insert, update and delete tick boxes greyed out in the 'configure the select statement' so i am unable to delete a colour and dog joined together. how can i delete something in the dog colours?

View 13 Replies

DataSource Controls :: How To Delete Related Data / Rows

May 5, 2010

How to delete related data.

Ex:

Tables:

1) Account: ID,UserName,Pass

2) Campaign: ID,AccountID,Date,Balance

3) CampaignSpec: ID,CampaignID,Spec,Color

Note: Account.ID = Campaign.AccountID and Campaign.ID = CampaignSpec.CampaignID

View 1 Replies

DataSource Controls :: How To Delete Data And Its Dependcies From Database

Feb 24, 2010

that is i want to delete my all he data of database but i want taht all the tables a andreletion will be remain same how can i do it easily

View 7 Replies

Web Forms :: GridView Delete Parameter Doesn't Delete Record

Jan 27, 2011

I have a gridview with edit and delete parameters enabled. When I click on the edit link, I can edit the record successfully. However when I click on the delete link, nothing happens (the record does not get deleted).

View 5 Replies

AJAX :: How To Confirm Or Delete Work With GridView Delete Button

Dec 14, 2010

I have a Gridview (VS2008 3.5) which has a Edit Button and a Delete button.he Delete button deletes the row without confirming deletion with the user first. ow can I use the Confirm/Delete Confirm from Ajax Toolkitif possible and if not, is there a way to Confirm/Delete with user firstwhen using Gridview?

View 6 Replies

DataSource Controls :: How To Delete The Duplicate Rows From Data Table

Mar 4, 2010

How do I remove duplicate rows from a data table based upon a two column values;I want to pass in a Data Table and a column names and get the data table back with data rows where that columns value are unique.

I have a Data Table with Duplicate Rows i want to delete the duplicates rows based upon two column values if both columns values are there then Delete the row.

View 8 Replies

DataSource Controls :: Using Sql Data Source / How To Delete Child Records In The First Step

Dec 4, 2010

how to delete child records in the first step

check if there is no more child using count row number if = 0 delete the key in parent table

parent table must have always child records in my case by Using sql data source Delete tab

View 3 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved