C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Interview   Jobs   Projects   Offshore Development    
Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing | Talk to Us |



My Profile

Gifts

Active Members
TodayLast 7 Days more...







datalist help meee.....


Posted Date: 11 Jul 2008      Total Responses: 3

Posted By: Rathi       Member Level: Gold     Points: 1


hai friends


good noon to all


how to delete the records in Datalist..... pls give me the solution.....

its very urgent..........




Responses

Author: UltimateRengan    11 Jul 2008Member Level: DiamondRating:     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 2008Member Level: DiamondRating:     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 2008Member Level: SilverRating:     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.



Post Reply
You must Sign In to post a response.
Next : this is a Interview Qst?
Previous : style sheet
Return to Discussion Forum
Post New Message
Category: ASP.NET

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design

silicone halloween masks

Contact Us    Privacy Policy    Terms Of Use