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

Cant visible button after click in radgrid

1 Answer 10 Views
Grid
This is a migrated thread and some comments may be shown as answers.
A770881
Top achievements
Rank 1
A770881 asked on 14 Sep 2013, 06:30 PM
i want visible Button1 when i click. version 2013.1.403.35
page aspx
<telerik:RadGrid ID="RadGrid1" runat="server" OnNeedDataSource="RadGrid1_NeedDataSource" AutoGenerateColumns="false" OnItemCommand="RadGrid1_ItemCommand" OnPreRender="RadGrid1_PreRender">
        <MasterTableView>
            <Columns>
                <telerik:GridTemplateColumn HeaderText="Edit Column" UniqueName="EditColumn">
                    <ItemTemplate>
                        <asp:Button ID="Button1" CommandName="Custom" CommandArgument='<%# Container.DataSetIndex + 1 %>' runat="server" Text="Button" />
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
                <telerik:GridBoundColumn DataField="Column1" HeaderText="Column1"></telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Column2" HeaderText="Column2"></telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Column3" HeaderText="Column3"></telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Column4" HeaderText="Column4"></telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Column5" HeaderText="Column5"></telerik:GridBoundColumn>
            </Columns>
        </MasterTableView>
    </telerik:RadGrid>
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadGrid1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>

CS:
List<int> updatedValues = new List<int>();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (ViewState["UpdatedValues"] != null)
        {
            updatedValues = ViewState["UpdatedValues"] as List<int>;
        }
    }
    protected void RadGrid1_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
    {
        DataTable table = new DataTable();
        table.Columns.Add("Column1");
        table.Columns.Add("Column2");
        table.Columns.Add("Column3");
        table.Columns.Add("Column4");
        table.Columns.Add("Column5");
 
        for (int i = 0; i < 20; i++)
        {
            table.Rows.Add("Col1Row" + i, "Col2Row" + i, "Col3Row" + i, "Col4Row" + i, "Col5Row" + i);
        }
 
        RadGrid1.DataSource = table;
    }
 
 
    protected void RadGrid1_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
    {
        if (e.CommandName == "Custom")
        {
            GridEditableItem item = e.Item as GridEditableItem;
            updatedValues.Add(item.ItemIndex);
 
            // My code processing
        }
    }
    protected void RadGrid1_PreRender(object sender, EventArgs e)
    {
        foreach (int index in updatedValues)
        {
            RadGrid1.MasterTableView.Items[index]["EditColumn"].Controls[0].Visible = false;
        }
 
        ViewState["UpdatedValues"] = updatedValues;
    }

Any solution?

Thanks!

1 Answer, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 16 Sep 2013, 05:31 AM
Hello,

foreach (int index in updatedValues)
        {
            (RadGrid1.MasterTableView.Items[index].FindControl("Button1") as Button).Visible = false;
        }


Thanks,
Jayesh Goyani
Tags
Grid
Asked by
A770881
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Share this question
or