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

[Solved] Grid always in edit mode

3 Answers 217 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Veshala
Top achievements
Rank 1
Veshala asked on 18 Nov 2009, 07:05 PM
Hi,

This is continuation to the previous ticket
http://www.telerik.com/community/forums/aspnet-ajax/grid/grid-always-in-edit-mode.aspx#1005390

I added the following code to make grid editable.
 protected void Page_Load(object sender, EventArgs e)
{
for (inti = 0; i < RadGrid1.PageSize;i++)
{
RadGrid1.EditIndexes.Add(i);
}
}


I have the paging applied on the grid. Whenever i click on next page, the page refreshes and grid going back to non editable mode.

How to make grid in editable mode all the time without additional rebinding .

Thanks

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 19 Nov 2009, 06:42 AM
Hi Veshala,

I tried the same code in DataBinding event of RadGrid and found it is working fine without additional rebinding.

CS:
 
    protected void RadGrid1_DataBinding(object sender, EventArgs e) 
    { 
        for (int i = 0; i < RadGrid1.PageSize; i++) 
        { 
            RadGrid1.EditIndexes.Add(i); 
        } 
    } 

Regards,
Shinu.
0
Veshala
Top achievements
Rank 1
answered on 20 Nov 2009, 02:16 PM
Hi Shinu,

Sorry for late reply. I was off yesterday.
I tried with following event. But it doesn't work for me.

protected void RadGrid1_DataBinding(object sender, EventArgs e)  
    {  
        for (int i = 0; i < RadGrid1.PageSize; i++)  
        {  
            RadGrid1.EditIndexes.Add(i);  
        }  
    }  

These are the following event handlers i have for RadGrid.

protected void Page_Load(object sender, EventArgs e) 
        { 
            for (int i = 0; i < grdAnnouncements.PageSize; i++) 
            { 
                grdAnnouncements.EditIndexes.Add(i); 
            }             
        }   
 
protected void grdAnnouncements_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e) 
        { 
            PopulateGrid(); 
        } 
 
protected void grdAnnouncements_DataBinding(object sender, EventArgs e) 
        { 
            for (int i = 0; i < grdAnnouncements.PageSize; i++) 
            { 
                grdAnnouncements.EditIndexes.Add(i); 
            } 
        }  
 
protected void grdAnnouncements_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) 
        { 
            if (e.Item is GridDataItem) 
            { 
                GridDataItem dataItem = e.Item as GridDataItem;                 
                CheckBox chk = (CheckBox)dataItem["Active"].Controls[0]; 
                chk.Checked = true
           
                dataItem["EditCommandColumn"].Controls[0].Visible = false
            } 
 
protected void grdAnnouncements_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e) 
        { 
            if (e.Item is GridEditableItem && e.Item.IsInEditMode) 
            { 
                LinkButton updateButton = (LinkButton)e.Item.FindControl("UpdateButton"); 
                updateButton.Visible = false
 
                LinkButton cancelButton = (LinkButton)e.Item.FindControl("CancelButton"); 
                cancelButton.Visible = false
            }             
        } 
 
 
 

I am attaching snapshot of page.

Please help me, it is very urgent.

Thanks for your help.
0
Martin
Telerik team
answered on 25 Nov 2009, 04:11 PM
Hello Veshala,

To make the answer of the support ticket available for the community I am also posting it here:

Below are listed the different approaches you can use to turn the grid items into edit mode.

Using the following code:

protected void MyGrid_ItemCreated(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridEditableItem)
        {
            (e.Item as GridEditableItem).Edit = true;
        }
    }

Here no additional rebind is required.

You can apply the following code on RadGrid PreRender event:

protected void MyGrid_PreRender(object sender, EventArgs e)
    {
        for (int i = 0; i < MyGrid.PageSize; i++)
        {
            MyGrid.EditIndexes.Add(i);
        }
        MyGrid.Rebind();
    }

This approach however requires you to rebind your grid after setting the items into edit mode.

Additionally, you can check out this help topic for more suggestions and details.

Let us know if you need further assistance.


Regards,
Martin
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Grid
Asked by
Veshala
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Veshala
Top achievements
Rank 1
Martin
Telerik team
Share this question
or