Aspx
<asp:DataList runat="server" CssClass="sample" RepeatLayout="Flow" ID="dlsamplecontent" RepeatDirection="Vertical" OnItemCommand="dlsamplecontent_ItemCommand">
<ItemStyle CssClass="tdContainer" />
<ItemTemplate>
//you code
</ItemTemplate>
</asp:DataList>
Aspx.cs
public void GetSamplingContentType()
{
try
{
ErrorLogger.gstrClientMethodName = this.GetType().FullName + "_" + System.Reflection.MethodBase.GetCurrentMethod().Name + " : ";
DataTable dt = new DataTable();
dlsamplecontent.DataSource = dt;
dlsamplecontent.DataBind();
}
catch (Exception ex)
{
ErrorLogger.ClientErrorLogger(ex);
}
}
Item Command and Retrieving Id using Command argument
protected void dlsamplecontent_ItemCommand(object source, DataListCommandEventArgs e)
{
try
{
int BlogId = Convert.ToInt32(e.CommandArgument.ToString());
if (e.CommandName == "SampleName")
{
//your code
}
}
catch (Exception ex)
{
ErrorLogger.ClientErrorLogger(ex);
}
}