This is a migrated thread and some comments may be shown as answers.

Custom Command Item Template Visibility Issue

1 Answer 54 Views
Grid
This is a migrated thread and some comments may be shown as answers.
zel
Top achievements
Rank 1
zel asked on 29 Sep 2010, 06:54 AM
Hello Everyone,

I tried the code in Retain expanded/selected state in hierarchy on rebind to save the state of grid as expanded/collapse. But I have another problem, every time I click on edit command item in detail 3 the other command item for detail 2 and master table also changes. Same goes to detail 2, every time i click on edit command item in detail 2 the command item master table also changes.

Please see the attached screenshots Before and After clicking the edit command item.

Below is my C# code for customizing the visibility of command items.
protected void gridCPDiag_ItemDataBound(object sender, Telerik.WebControls.GridItemEventArgs e)
        {
            if (e.Item is GridCommandItem && e.Item.OwnerTableView.Name == "Detail2")
            {
                GridCommandItem visitcommandItem = (GridCommandItem)e.Item;
                LinkButton visitbtnAdd = (LinkButton)visitcommandItem.FindControl("det2_btnAdd");
                LinkButton visitlnkPerformInsert = (LinkButton)visitcommandItem.FindControl("det2_lnkPerformInsert");
                LinkButton visitbtnEditSelected = (LinkButton)visitcommandItem.FindControl("det2_btnEditSelected");
                LinkButton visitbtnUpdateEdited = (LinkButton)visitcommandItem.FindControl("det2_btnUpdateEdited");
                LinkButton visitbtnCancel = (LinkButton)visitcommandItem.FindControl("det2_btnCancel");
                LinkButton visitbtnDelete = (LinkButton)visitcommandItem.FindControl("det2_btnDelete");
 
 
                if (hdnCommandName.Value == "det2_initinsert" || hdnCommandName.Value == "det2_editselected")
                {
                    visitbtnAdd.Visible = false;
                    visitbtnEditSelected.Visible = false;
                    visitbtnDelete.Visible = false;                   
                    visitbtnCancel.Visible = true;
                }
 
                if (hdnCommandName.Value == "det2_initinsert")
                {
                    visitlnkPerformInsert.Visible = true;
                }
                if (hdnCommandName.Value == "det2_editselected")
                {
                    visitbtnUpdateEdited.Visible = true;
                     
                }
 
                if (hdnCommandName.Value == "det2_performinsert" || hdnCommandName.Value == "det2_update" || hdnCommandName.Value == "det2_cancelall")
                {
                    visitbtnAdd.Visible = true;
                    visitbtnEditSelected.Visible = true;
                    visitbtnDelete.Visible = true;
                    visitlnkPerformInsert.Visible = false;
                    visitbtnUpdateEdited.Visible = false;
                    visitbtnCancel.Visible = false;
                }
 
            }
 
            if (e.Item is GridCommandItem && e.Item.OwnerTableView.Name == "Detail3")
            {
                GridCommandItem inscommandItem = (GridCommandItem)e.Item;
                LinkButton insbtnAdd = (LinkButton)inscommandItem.FindControl("det3_btnAdd");
                LinkButton inslnkPerformInsert = (LinkButton)inscommandItem.FindControl("det3_lnkPerformInsert");
                LinkButton insbtnEditSelected = (LinkButton)inscommandItem.FindControl("det3_btnEditSelected");
                LinkButton insbtnUpdateEdited = (LinkButton)inscommandItem.FindControl("det3_btnUpdateEdited");
                LinkButton insbtnCancel = (LinkButton)inscommandItem.FindControl("det3_btnCancel");
                LinkButton insbtnDelete = (LinkButton)inscommandItem.FindControl("det3_btnDelete");
 
 
                if (hdnCommandName.Value == "det3_initinsert" || hdnCommandName.Value == "det3_editselected")
                {
                    insbtnAdd.Visible = false;
                    insbtnEditSelected.Visible = false;
                    insbtnDelete.Visible = false;
                    insbtnCancel.Visible = true;
                }
 
                if (hdnCommandName.Value == "det3_initinsert")
                {
                    inslnkPerformInsert.Visible = true;
                }
                if (hdnCommandName.Value == "det3_editselected")
                {
                    insbtnUpdateEdited.Visible = true;
 
                }
 
                if (hdnCommandName.Value == "det3_performinsert" || hdnCommandName.Value == "det3_update" || hdnCommandName.Value == "det3_cancelall")
                {
                    insbtnAdd.Visible = true;
                    insbtnEditSelected.Visible = true;
                    insbtnDelete.Visible = true;
                    inslnkPerformInsert.Visible = false;
                    insbtnCancel.Visible = false;
                }
            }
        }

Please help. I would really appreciate for any response.

Thanks!
Zel

1 Answer, 1 is accepted

Sort by
0
zel
Top achievements
Rank 1
answered on 29 Sep 2010, 07:52 AM

Please disregard my problem below. I already figured it out why is the master table command items changes, every time i click on edit in any detail table.

Thanks!
Zel
Tags
Grid
Asked by
zel
Top achievements
Rank 1
Answers by
zel
Top achievements
Rank 1
Share this question
or