Forms Data Controls :: Deleting In Detailview Without Using Datasource?
Mar 18, 2010how to delete from detailview without using datasource?
And it also doesnt work using sql datasource .
how to delete from detailview without using datasource?
And it also doesnt work using sql datasource .
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]....
I can use similar code below to select a row in my database when I enter a value (username) in text box and it successfully retrieves.however, I'd also like to delete row from database based on the username i enter in text box. My code runs but no row is deleted...my code is:
SQL:
private AdminTableAdapter adminGetUsers;
From my Employees table of the Northwind database, how do I delete a row? I have a row with a LastName field = WWWW How to write the string sql?
SqlConnection con = new
SqlConnection(connectionString);
string sql =
"DELETE FROM Employees WHERE LastName =" + WWWW;
SqlCommand cmd =
new
SqlCommand(sql, con);
I'm looking for ideas on deleting data from the multiple SQL tables with LINQ (C#).
My existing solution does the following:
1. DeleteAllOnSubmit( Subset of the data from the child table)
2. DeleteAllOnSubmit( Subset of the data from another child table)
3. DeleteAllOnSubmit( Data from the parent table)
4. CommitChanges()
All this resides within a single method, which makes it ugly and not re-usable.
I have considered the following alternatives, but I decided not to use them:
1. Cascade delete on the tables.
2. Do a join on all tables from which I will remove the data, but I'm not sure yet whether I could pass a join query to DeleteAllOnSubmit().
3. Write stored procedure(s) to delete data from each table. I don't have the time to implement this due to a large number of tables and the time constraints.
I know you've heard these questions, one million of times:1) I have a profile page with firstName, lastName, address1, address2, etc. and county as a 3 chars countryID, like USA for United States, GBR for Great Britain, etc. How do I connect the countries table (contains countryID and countryName columns) to display United States instead of USA? Of course I also need to update it selecting a country name (not ID) ?2) What will happen when I will need to give the page a more attractive look? Is this DetailView easily convertible in plain HTML form?
View 12 RepliesI WANT to make a signup with the help of Detailview....I also want to add a captcha control in detail view to stop spamming...
View 4 Repliesi'm tring to make my detail view to update
i have a update button , once i click it , i can update my data from the detailview
but its not working at all for some reason
[code]....
I'm trying to link a detailview to a gridview. Both are using the same datasource control and it's coming from an Access database. Both are showing data. The gridview is listing products fine and the detailview is listing details of some default product (maybe the first). How can I configure the two so that when I hit my select button on my gridview that it populates the details into detailview with the correct data for the selected product?
View 1 Replies[Code]....
I am trying to store decimal values from detailview. But it doesn't work. It stores decimal values after rounding. Let's say if I enter length/width as 4.2000 then in sql it stores as 4.0I am using sql server 2008 and the field is defined as decimal(8,4).I tried diff combination but nothing is working.
I use detailview control for edit all data in page but when i save data and i need save current username it's not save.
Now 1. I'm try use <asp:Parameter Name="<%$ Page.User.Identity.Name %>" Type="String" /> but not work.
2. I'm try use find control in codebehind and fill data to label in detailview but not work.
Below is my code.
[Code]....
I have a gridview and detailview in an updatepanel. My detailview is setup to display the details of a record that is selected in the gridview. When I edit the values in the detailview and click update it does not update the gridview. If I check my database the values have been changed it just haven't been updated in my gridview. Below is my code for the two objects and their datasources.
<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
AutoGenerateColumns="False" DataSourceID="RCR_DSM" AllowSorting="True"
DataKeyNames="PartNumber" AutoGenerateSelectButton="True">
<Columns>
[Code]....
I am currently working on a project now, i have created a web form and successfully stored the data when the user fills in the textfield, dropdownlist and radiobutton and clicks on the submit button. Now, i need to show the lastest data entry in a detailview in a new page when the user clicks the submit button. Is this posible? How should i go about it? Or is there any other way for i did not use a gridview for users to enter their information.
View 5 RepliesI am using a DetailsView control to allow for updating a user record. Is there a way to check if the values are actually updated/changed when the update link is clicked. I know there are users, who would click the update button rather than the "Canel" even if there are no changes to the record. So, how do I check if any value has been updated when the update link is clicked. The DetailsView uses a SqlDataSource to populate the DetailsView.
View 4 RepliesI would like to know how to use the generatedimage control in a detailview to resize images using VB
View 4 RepliesI'm trying to change a row in detailsview based on a value in a coloum. Exactly the same as this example but in Detailsview: [URL]
View 3 RepliesI want to display image in detailview.. I used image datatype in the database instead of using varbinary. but the problem is.. detail view is not fetching the picture..
how i display the picture of datatype image.
I have 3 tables User, role and UserInRole THe entity frame work made entities for User and Role and I have successfully made a join with the user and role entities using user.add(role); but I can't seem to get it to remove the link (I want to retain the user and role just remove their association).
using (ProviderEntities context = new ProviderEntities())
{
User u = context.User
.Where(n => n.ApplicationName == application)
.Where(n => n.Username == username).First();
Roles r = context.Roles
.Where(n => n.ApplicationName == application)
.Where(n => n.RoleName == roleName)
.First();
r.User.Remove(u);
context.SaveChanges();
}
The oposite worked when I did r.User.Add(u); but it wont let me now remove it after it been created. Driving me mad as I can't see where I have gone wrong.
I have table with 1000 rows. is it possible to delete top 500 rows with truncate statement ??
View 2 RepliesI searched a lot of threads but still couldn't get my problem fixed. I have to update the "regform" table with two fields: session_ and session2. These two fields are inside the detailview edititem template which bounded to dropdown list drpsession1, drpsession2 separately. I wanted to pass the update parameters to the update sql UPDATE dbo.regform SET session_=@session_, session2=@session2 where id=@id
the @session_ is bounded to a drpsession1 and @session2 is bounded to drpsession2. I used
ControlID="ctl00$ContentPlaceHolder1$DetailsView1$drpsession1" to access the dropdown list within the detailview, but still couldn't do the updates. What's wrong with my code? Do I have to use the code behind to specify the update parameters? and How to do it? TIA.
<
"
asp:DetailsView
ID="DetailsView1"
runat="server"
AutoGenerateRows="False"
DataSourceID="SqlDataSource2"
Height="50px"
Width="544px"
DataKeyNames="id"
ondatabound="DetailsView1_DataBound">
<Fields>
<
asp:TemplateField
HeaderText="Session -Part I"
SortExpression="session_">
<
EditItemTemplate>
<asp:DropDownList
ID="drpsession1"
runat="server"
DataSourceID="SqlDataSource3"
DataTextField="session_time"
DataValueField="session_id"
SelectedValue='<%# Bind("session_") %>'
AppendDataBoundItems="True"
Width="229px">
<asp:ListItem
Text="Please select"
Value="-1"
/>
</asp:DropDownList>
<asp:SqlDataSource
ID="SqlDataSource3"
runat="server"
ConnectionString="<%$ ConnectionStrings:Connstr %>"
SelectCommand="SELECT dbo.sessions.* FROM dbo.sessions"></asp:SqlDataSource>
</EditItemTemplate>
<
asp:TemplateField
HeaderText="Session - Part II"
SortExpression="session2">
<EditItemTemplate>
<asp:DropDownList
ID="drpsession2"
runat="server"
DataSourceID="SqlDataSource4"
DataTextField="session_time"
DataValueField="session_id"
SelectedValue='<%# Bind("session2") %>'
AppendDataBoundItems="True"
Width="234px">
<asp:ListItem
Text="Please select"
Value="-1"
/>
</asp:DropDownList>
<asp:SqlDataSource
ID="SqlDataSource4"
runat="server"
ConnectionString="<%$ ConnectionStrings:Connstr %>"
SelectCommand="SELECT dbo.sessions2.* FROM dbo.sessions2">
</asp:SqlDataSource>
</EditItemTemplate>
</Fields>
</asp:DetailsView>
<
asp:SqlDataSource
ID="SqlDataSource2"
runat="server"
ConnectionString="<%$ ConnectionStrings:Connstr %>"
UpdateCommand
where regform.id=@id">
="UPDATE dbo.regform SET session_=@session_, session2=@session2 where id=@id">
<UpdateParameters>
<asp:ControlParameter
ControlID="ctl00$ContentPlaceHolder1$DetailsView1$drpsession1"
Name="session_"
PropertyName="SelectedValue"
Type="String"
/>
<asp:ControlParameter
ControlID="ctl00$ContentPlaceHolder1$DetailsView1$drpsession2"
Name="session2"
PropertyName="SelectedValue"
Type="String"
/>
<asp:ControlParameter
ControlID="DetailsView1"
Name="id"
PropertyName="SelectedValue"
/>
</UpdateParameters>
</asp:SqlDataSource>
I am trying to bind upto 3 values to a HyperLink control in a DetailView control to create a query string but it does not seem to work.
Following is my code for the HyperLink:
[Code]....
The parameters UserName, FirstName and LastName are column names from the sqldatasource.
i have design a web application having suppliers table using SqlDatasource..
i have a master page in my design and other form are bound to a context menu..
Now i have displayed the records in the gridview..all i wanted is after i select a record in the gridview it will display the selected record in detailview from another aspx form..
i was able to create the link to another aspx form but the data that it display is the first data from the gridview not the data that i select.
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 Replieshow can i retrieve the all foreign keys against a single primary key. i mean to say that if a table contain a primary key then it becomes as foreign keys in which tables.
i want to take that nam of that tables and on the base of that tables then i am to delete from all the entries. e.g: if a primary key's column entry deleted then all foreing key entries should also be deleted.
there are 988 tables in a single database. it can't be possible to go for each table to setup foreign key to ON DELETE CASCADE.
.can it have any way to delete against foreign key priority wise? mean to say that parent table contain primary key, child table contain foreign key , now there is another child table which dependent previous child table. then how can i delete all record against it?
i want to do it from programatically. i am using sql server 2005
i have completed this till to that , it retrieves all foreign keys but how to delete now on the base of priority.
[Code]....
I am using VS2005 and SQL Server 2005. The problem I am having is when I call my SQLDataSource to delete rows the delete is firing twice. The trace and debugging show the code executing once. In fact right after the delete, the table only shows one delete, but right after the command function is exited the 2nd row is deleted. Also, I have tested the stored procedure to make sure it only deletes 1 one and then resequences the records.Show below are excerpts from my .aspx and code behind files.
[Code]....