Creation of repeater dynamically.

Jaggi237
Posted by Jaggi237 under C# category on | Points: 40 | Views : 1499
public void DynamicRepeater()
{
dv.Controls.Clear();
Repeater rpt = new Repeater();
rpt.ItemDataBound += rptr_ItemDataBound;
rpt.DataSource = lstAllActivity
rpt.DataBind();
rpt.EnableViewState = false;
dv.Controls.Add(rpt);
}
else
{
rpt.DataSource = null;
rpt.DataBind();
}
}

protected void rptr_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
ActivityMasterEntity act = (e.Item.DataItem as ActivityMasterEntity);
RepeaterItem repeaterItem = new RepeaterItem(e.Item.ItemIndex, ListItemType.Item);
LiteralControl lblBegin = new LiteralControl();
LiteralControl lblEnd = new LiteralControl();
Repeater rpt = new Repeater();
rpt.ID = "rpt";
hdnActivityId.Value = act.ActivityId.ToString();
LinkButton dynamicLnkAddButton = CreateDynamicAddLnkBotton();
LinkButton dynamicLnkRemoveButton = CreateDynamicRemoveLnkBotton();
lblBegin.Text = "<div style='padding-top:5px; padding-bottom:5px; padding-left:75px; border:1px #8f989c Solid; white-space: nowrap!important; overflow: hidden!important; text-overflow: ellipsis!important;' class='col-md-12'>" + act.ActivityDescription + "</br>";
lblEnd.Text = "</div>";
List<ActivityMasterEntity> lstAct = lstAllActivity.FindAll(x => x.ParentId == act.ActivityId);
rpt.ItemDataBound += rptr_ItemDataBound;
rpt.DataSource = lstAct;
rpt.DataBind();
repeaterItem.Controls.Add(lblBegin);
repeaterItem.Controls.Add(dynamicLnkAddButton);
repeaterItem.Controls.Add(dynamicLnkRemoveButton);
repeaterItem.Controls.Add(rpt);
repeaterItem.Controls.Add(lblEnd);
e.Item.Controls.Add(repeaterItem);
}
}

private LinkButton CreateDynamicAddLnkBotton()
{
LinkButton dynamicAddLnkButton = new LinkButton();
dynamicAddLnkButton.ID = "btnAddSubItems" + "$" + hdnActivityId.Value;
dynamicAddLnkButton.CommandName = "AddSubActivities";
dynamicAddLnkButton.CommandArgument = hdnActivityId.Value;
dynamicAddLnkButton.CssClass = "btn btn-success btn-xs glyphicon glyphicon-plus";
dynamicAddLnkButton.Style["Position"] = "Absolute";
dynamicAddLnkButton.Style["Left"] = "10px";
return dynamicAddLnkButton;
}

private LinkButton CreateDynamicRemoveLnkBotton()
{
LinkButton dynamicRemoveLnkButton = new LinkButton();
dynamicRemoveLnkButton.ID = "btnRemoveSubItems" + "$" + hdnActivityId.Value;
dynamicRemoveLnkButton.CommandName = "RemoveSubActivities";
dynamicRemoveLnkButton.CssClass = "btn btn-danger btn-xs glyphicon glyphicon-remove";
dynamicRemoveLnkButton.Style["Position"] = "Absolute";
dynamicRemoveLnkButton.Style["Left"] = "35px";
return dynamicRemoveLnkButton;
}

Comments or Responses

Posted by: Outlookchangepassword on: 6/1/2018 Level:Starter | Status: [Member] | Points: 10
http://www.outlooksupportphonenumbers.com/outlook-change-password/

Here Outlook Phone Number +1-800-311-6894 That gives you the solution of any error and message and any Outlook Change Password Or Outlook Sig Up problem just dial Outlook Tech Support number and get best experts advice 24*7 through our Outlook Support Number.
Posted by: Vikasdotnet on: 6/12/2018 Level:Starter | Status: [Member] | Points: 10
very nice article you shared.
if you want to know the technologies updates,visit below site.

http://www.dotnetbasic.com

Login to post response