Forms Data Controls :: Deleting Item From Datalist Using C#?
Mar 29, 2010
here's my issue:I want to delete an item from a datalist and i cant seem to get it working. I am using the delete code from a sqldatasource which is..
[Code]....
I have searched on the web for code for this, but all i can find is code to delete the primary key from from a table. My issues is that i have a double primary key.The way that it works is, i insert a load of data, but which uses number1 as the first primary key, and number 2 is like an item of number1 as such.Sorry about the explanation, if you dont understand i'd happily try and explain it better.
View 13 Replies
Similar Messages:
Mar 31, 2010
I am learning how to use repeater. I added two links to my repeater, a delete and an edit link. However, when I click either delete or edit link, they both take me to same method. How do I add the link such that when I click on edit, it take me to an edit method and delete takes me to a delete method. Below is a sample code.
Also, how do I delete a single row in a repeated. For example, I have a simple form that display an item description and a quantity. There are six item display on the form, but I wish to delete the third item. How can I pass in an id that will delete the third item rather than delete everything (i.e where item_id = 3)
[Code]....
View 6 Replies
Sep 27, 2010
I have a repeater which binds a set of data. Within this repeater is a column with various controls for updating, deleting, etc. These are image buttons which fire an onclick event such as "DeleteRecord". All this does is fire a stored procedure, passing in the ID of the record to delete from the CommandArgument of the object.
This works wonderfully... except for one rather huge problem. Once you delete a record, if you refresh the page, the record where the first deleted record used to be gets deleted. For instance... if I have 4 records
1 Record1
2 Record2
3 Record3
4 Record4
and I delete record 2... The page reloads with (which is fine):
1 Record1
3 Record3
4 Record4
...if I then hit refresh...
1 Record1
4 Record4
I assume this is because the erroneously deleted object (record3) is now in the same hierarchical place as the old object used to be and .net therefore doesn't know the difference, the page refreshes and fires the onlick event, grabbing out the command argument of the new object and deletes based on the ID as obtained from the commandargument of the new object. This is obviously a huge problem, if a client did this it would destroy data erroneously and I'm at a loss here. Is there any way to stop this from happening? I'm not sure if there is a better way to go about doing things or not. If there isn't, I need some sort of way to tell the page not to execute the event or to cross reference the ID of the object that is intended for deletion against the object itself...
Code below for convenience...
EDIT Wrapped a LinkButton around it because I have some jquery code in here as well which stops the page execution to wait for user confirmation. Pressing "ok" continues page execution.
<asp:LinkButton ID="oDeleteLink" CssClass="oDeleteIcon" CommandName="Delete" CommandArgument='<%# Eval("iAccountID") %>' runat="server">
<asp:ImageButton ImageUrl="/files/system/icons/trash-steel-16.png" ToolTip="Delete This Account" AlternateText="Delete" ID="oDeleteIcon" runat="server" />
</asp:LinkButton>
protected void oAccounts_ItemCommand(Object Sender, RepeaterCommandEventArgs e) {
if (e.CommandName == "Delete") {
int ID = e.CommandArgument.ToString().Numeric();
db.SPs.SpDeleteAccount(ID).Execute();
UI.Confirm(uiBroadcast, "Account has been deleted", "300px");
BindAccounts();
}
}
View 2 Replies
Nov 4, 2010
I have the following DataList control:
[Code]....
When I click on the LinkButton, I want to insert the current item in the DataList into the database via LINQ to SQL in C# code behind. In the codeb behind, how do I retrieve that particular item so I can insert it into the database?
View 2 Replies
Dec 31, 2010
i'm trying to get a datalist item to string, but i keep getting this error??
Object reference not set to an instance of an object.
[Code]....
View 10 Replies
Sep 29, 2010
i have 3 items in my dataliste but the
Label46.Text = DataList2.Items.Count gives me 2.
View 10 Replies
Mar 25, 2010
I'm trying to figure out how can I control my linkbutton which nests inside my DataItem in the ItemTemplate.What I wish to do is to check something in the server side and according to that, decide whether I wish to alter its visibility to "true" or to keep it hidden. I think that the method which is going to solve it is the ItemCreated, although, I don't happen to know how to control that specific item of mine.
Here is my DataList control:
[Code]....
View 1 Replies
Jun 2, 2010
I have a data list , each row consist only from button , i want to retrive data from data base depending on the item, I mean each button or row have different tooltip , it is possible to do this ?
if the button is enable=false also it is possible ?
View 7 Replies
Jul 16, 2010
i don't know english very well sorry about that and my question isi have datalist in my web page like this
<div style="height: 550px;">
View 13 Replies
Feb 15, 2011
I have the following line to display a piece of data and I want to know how I can format the output.
Text='<%# Eval("DOH") %>'
The data list displays the correct data, but I want to format it. The output I want is just a small date format instead of date and time. I have tried every combination of a format function I can think of, but can't seem to make it work. Am I stuck with the raw format provided by the database? I wouldn't think so, but maybe that is the case.
expected output should be 02/15/2011 instead of 02/15/2011 09:45:
View 2 Replies
Jan 17, 2010
I am using the following code with a datalist, but how can I change the date format of the PublicationAddDate Field, it is not displaying as expected, even though it is in the correct format in my DB.
[Code]....
View 1 Replies
Sep 17, 2010
I have a datalist which is filled by a LinqToSQL query.
I have put a edititemtemplate in it, whith a update button,
Everything works fine, but when i ask the value of the textbox in update mode it still has the old value and not the new value typed from the textbox, anyone got a clue?
[Code]....
View 8 Replies
May 4, 2010
i am making a site like linkedini have a datalist which show the search of peoples from database. my problem is that, i have mixed data to show in datalist.suppose datalist going to show only 2 label values, first is "who" second is "type". who can be of 4 types just like linkedin search, "A student","employ",Bussiness owner", "working independent"when student is pick in one label from database then college will be display in second labelwhen employ is pick in one label then company will be display in second column.It means i cannot bind the second label at designtime. and even at run time i have to bind each item of second label with approprite to first label. bec search can be mixed, means if 10 peoples are searched, then may be someone is employ, someone is student, and second label should show value appropriate their first label.
View 2 Replies
Jan 6, 2010
I want to show a message when there's no data in my datalist. I found the following, but, I get an error on the bool. If you have another way to do this, great, but, I'd also like to try to do it this way as a learning experience.
<asp:DataList id="DataList3" runat="server" DataSourceID="SqlDataSource1">
<ItemTemplate>
<asp:HyperLink ID="ID" runat="server" target="_parent" NavigateUrl='<%# "Employment_detail.aspx?"%>'
Text='<%# Bind("WJTTL") %>'/>
</ItemTemplate>
<FooterTemplate>
<asp:Label ID="lblEmpty"
Text="Nothing here." runat="server" Visible="true">
%>Visible='<%#bool.Parse((SqlDataSource1.Items.Count==0).ToString())%>'> </asp:Label>
</FooterTemplate>
</asp:DataList>
View 1 Replies
Mar 3, 2011
I have a DataList control setup with a Repeater inside it. It's displaying Ranks just fine, but the problem is I don't know how to make it start over with each DataList.
Right now, if there are two rows in the PointsCat table, it creates two DataLists (new DataList for each ID) and populates the Repeater with the person's rank, name and points from the Points table. The CatID in the Points table is a number equal to an ID in the PointsCat table (to tell which DataList's Repeater to display the data in). This code currently just orders ALL the entries from my database table, so the first Repeater in the first DataList may end with a ranking of 4 (4th), the first item in the next DataList's Repeater starts with a rank of 5...instead of starting over with 1.
So my current page may show something like this (notice the rank didn't start over in the second category):
Points Category 1 Points Category 2
1 John Doe 400 4 Janet Doe 275
2 John Smith 390 5 Johnny Smith 270
3 Jane Smith 380
My SqlDataAdapter line is below. I need it to start over the ranking for each CatID. Is it possible to do that within this line?
[Code]....
View 6 Replies
Aug 10, 2010
[Code]....
show DataList Item Index when using SqlDataSource?
View 4 Replies
Mar 14, 2011
I have the below label. I need it to be a link that will cause the following:
Existing label INSIDE a DataList Item Template;
<asp:Label ID="Label10" runat="server" Text='<%# Eval("CG_ID") %>' Font-Size="X-Small"></asp:Label>
I need to change this label to a link that will cause C# code behind to:
tbxCG_ID.Text = Eval("CG_ID")
and then call this:
protected void ListBox1_SelectedValueChanged(object sender, EventArgs e)
I keep creating a DataList1_SelectedIndex_Changed event created when I double click the label or a link button. What is the code needed? I can see the Eval("CG_ID") value with the label but I don't know how to get it into tbxCG_ID.Text and fire the ListBox1 event.
View 2 Replies
Apr 28, 2010
I've constructed a simple horizontal DataList that will contain 'N' number of items. I'm now trying to wire it up so that when the user clicks on any item a server-side event is fired. To accomplish this I'm following this article: [URL]
Here's the critical code I have so far:
[Code]....
View 5 Replies
May 25, 2010
I have a rather large datalist on which I have implemented an editing capability. When I click on my edit link, everything works as expected except that when I bind my data focus returns to to the top of the screen, so my user will have to scroll all the way back down to the item he wants to edit. Is there a way to keep the page centered on the item in question through the databind?
View 2 Replies
Oct 10, 2013
I have one datalist,in datalist one column is UserName and in second column one button i.e. Delete. When I click on Delete then delete the this row from datalist.how to create this functionality.
View 1 Replies
Jul 17, 2015
<asp:DataList ID="dlmycart" runat="server" RepeatLayout="Table" RepeatColumns="1"
RepeatDirection="Horizontal" CellPadding="0" CellSpacing="0" BackColor="Aqua"
Width="100%">
<ItemStyle Width="80%" BackColor="Violet" />
<ItemTemplate>
<table border="0" style="width: 100%; height: 300px; border: 2px solid Blue; background-color: ; text-align: center">
[Code] ....
View 1 Replies
Jul 6, 2012
I have following datalist ,to display employee id, name, email ..... datalist have column with link button text " Get Details" and fontcolor "black" , onmouseover of the particular row i want change the color of linkbutton or the image of linkbutton ..
<asp:DataList ID="DataList1" runat="server" BorderWidth="1px" CellPadding="1"DataKeyField="EMPID"
GridLines="Both" RepeatColumns="4" RepeatDirection="Horizontal"><ItemTemplate><table border="0" id="thistable" runat="server" style="width:100%;height:100%"> <tr> <td> EMPID:
<asp:Label ID="EMPIDLabel" runat="server" Text='<%# Eval("EMPID") %>'>
[code]...
View 1 Replies
May 7, 2015
How to make the entire datalist item to clickable.....
View 1 Replies
Feb 25, 2016
<asp:DataList ID="dtListOtherItems" runat="server" ClientIDMode="Static" RepeatDirection="Horizontal" DataKeyField="Price" RepeatColumns="4" OnItemCommand="dtListOtherItems_ItemCommand" OnItemDataBound="dtListOtherItems_ItemDataBound">
<ItemTemplate>
<asp:ImageButton ID="imgCategory" runat="server" ImageUrl='<%#Bind("Image") %>' Height="100px" Width="100px" CommandName="Select" CommandArgument='<%#Bind("ProductID") %>' /> <br />
[Code] ....
I need to change the txtOrderQty textbox value when btnAdd click event using jquery
View 1 Replies
Jun 25, 2012
i want to display the tooltip using datalist control,
eg i had column like
prodname, more_detail, rate
when i mouse hover on prod_name then display the more_detail near product.
View 1 Replies