Hi
I did some code for your requirement check it once
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
<script language ="javascript" >
function postrowtodel(id) {
$.get("default12.aspx?action=delete", { name: id }, function (data) {
location.reload();
});
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:datalist id="DataList1" runat="server" xmlns:asp="#unknown">
<HeaderTemplate >
<table width="100%"><tr><td>first col</td><td>second col</td></tr>
</HeaderTemplate>
<itemtemplate>
<table><tbody><tr><td><a href="javascript:postrowtodel('<%# Container.DataItem %>')">Delete</a></td><td><![CDATA[<%# Container.DataItem %>]]></td></tr></tbody></table>
</itemtemplate>
<footertemplate>
</footertemplate></table>
</asp:datalist>
</div>
</form>
</body>
</html>
and code behind file contains following code
if (!IsPostBack)
{
List<string> list;
if (Request.QueryString["action"] != null)
{
if (Request.QueryString["action"].ToString() == "delete")
{
Response.Clear();
list = (List<string>)Session["DataSource"];
list.Remove(Request.QueryString["name"].ToString());
Response.Write("");
Response.End();
}
}
else
{
if (Session["DataSource"] != null)
{
list = (List<string>)Session["DataSource"];
}
else
{
list = new List<string>();
list.Add("Bread");
list.Add("Cheeze");
list.Add("Wine");
list.Add("Beer");
list.Add("Waffles");
Session["DataSource"] = list;
}
DataList1.DataSource = list;
DataList1.DataBind();
}
}
</string></string></string></string>
I hope you understood what I did
All the Best