| Author: UltimateRengan 11 Jul 2008 | Member Level: Diamond | Rating: Points: 1 |
hi, DataTable aTable = (DataTable)DataList1.DataSource; aTable.Rows[e.Item.ItemIndex].Delete(); // Bind the data after the item is deleted. DataList1.DataBind();
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1660723&SiteID=1
i hope this may help u
|
| Author: Danasegarane.A 11 Jul 2008 | Member Level: Diamond | Rating: Points: 3 |
This will help you
DataList1.DataSource = Nothing DataList1.DataBind()
I am setting the datasource to null annd rebinding the data. So no datawill beshown in the datalist
|
| Author: jayant 11 Jul 2008 | Member Level: Silver | Rating: Points: 6 |
pl try this,
protected void dlcart_DeleteCommand(object source, DataListCommandEventArgs e) { int prodid = Convert.ToInt32(((Label)dl.Items[e.Item.ItemIndex].FindControl("scrapid")).Text.Trim()); deletefrmcart(prodid); BindList(); }
public void deletefrmcart(int idpd) { try { if (conn.State == ConnectionState.Closed) conn.Open(); cmd = new SqlCommand(); cmd.Connection = conn; cmd.CommandText = "delete from tbl where id= "+ idpd; cmd.ExecuteNonQuery(); cmd.Dispose(); } finally { if (conn.State == ConnectionState.Open) conn.Close(); } }
<asp:DataList ID="dlcart" runat="server" Width="100%" OnDeleteCommand="dlcart_DeleteCommand">
<asp:Button ID="btndel" CommandName="delete" Text="Remove" runat="server" />
Bcoz ur code will not reflect in database. u have to manually delete this by firing the record.
currently i m using this and works fine.
|