Asp.Net Datalist Assign Autonumber

If  u want to assign Datalist item count then write the following code in ItemDataBound  of Datalist protected void Datalist1_ItemDataBound(object sender, DataListItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
if (dd.Tables[0].Rows.Count > 0)
{
Label id = e.Item.FindControl(“lblId”) as Label;
int auto = e.Item.ItemIndex + 1;
id.Text = ” Item ” + auto.ToString();
}

}
}

This Code will find the Lable in Datalist and Assign it  Auto number.

Advertisement

One thought on “Asp.Net Datalist Assign Autonumber

  1. Hi my loved one! I wish to say that this
    article is awesome, nice written and include approximately all significant infos.
    I would like to peer extra posts like this .

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s