dimanche 28 septembre 2014

Dynamic List View Control Asp.net C#


Vote count:

0




I have Created One Composite Control which is consist of List View Control , Created Edit Item Template Event its not working properly.


following is My Code.


this.itemValueListView = new ListView(); this.itemValueListView.ID = "ItemValueListViewId"; this.itemValueListView.ItemTemplate = new ItemTemplate(); this.itemValueListView.EditItemTemplate = new EditItemTemplate(); this.Controls.Add(itemValueListView);


private class EditItemTemplate : ITemplate { public void InstantiateIn(Control container) { var tbl1 = new HtmlGenericControl("table"); var tr1 = new HtmlGenericControl("tr"); var td1 = new HtmlGenericControl("td"); td1.DataBinding += DataBinding; tr1.Controls.Add(td1); tbl1.Controls.Add(tr1); container.Controls.Add(tbl1); }



` public void DataBinding(object sender, EventArgs e)
{
var container = (HtmlGenericControl)sender;
var dataItem = ((ListViewDataItem)container.NamingContainer).DataItem;

container.Controls.Add(new TextBox() { Text = dataItem.ToString(), ID = "ItemTextBoxID", Enabled = false });
container.Controls.Add(new Button() { Text = "Update", ID = "EditButtonId", CausesValidation = false, CommandName = "Update" });
container.Controls.Add(new Button() { Text = "Cancel", ID = "EditButtonId", CausesValidation = false, CommandName = "Cancel" });

}
}`


` protected override void OnInit(EventArgs e) { base.OnInit(e); this.Page.RegisterRequiresControlState(this); this.itemValueListView.ItemCommand += this.itemValueListView_ItemCommand; this.itemValueListView.ItemEditing += this.itemValueListView_ItemEditing;



}`

`protected override void OnLoad(EventArgs e)
{
if (this.Page.IsPostBack)
{
this.itemValueListView.DataSource = this.ItemValueList;
this.itemValueListView.DataBind();

this.value = string.Join(",", this.ItemValueList.ToArray());
}
}`


when ever I am clicking on Edit it is not showing in Editable format.



asked 25 secs ago







Dynamic List View Control Asp.net C#

Aucun commentaire:

Enregistrer un commentaire