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

GridTemplateColumn controls on edit and insert mode

4 Answers 278 Views
Grid
This is a migrated thread and some comments may be shown as answers.
jo
Top achievements
Rank 1
jo asked on 21 Jul 2008, 06:26 PM

On my grid i'm using a GridTemplateColumn .I would like to visible or enable only on insert mode.I'm using Edit form method.
<
telerik:GridTemplateColumn UniqueName="CompanyName" HeaderText="Company Name">

<ItemTemplate>

<%

#DataBinder.Eval(Container.DataItem,"CompanyName")%>

</ItemTemplate>

<EditItemTemplate>

<telerik:RadComboBox DataTextField="CompanyName" DataValueField="CompanyName"

EnableLoadOnDemand="False" ID="cmbCompanyName" runat="server" Height="140px" Width="150px"

Skin="Mac" SelectedValue='<%#Bind("CompanyName") %>' DataSourceID="ObjSourceCompany">

</telerik:RadComboBox>

</EditItemTemplate>

</telerik:GridTemplateColumn>


Thnaks!!

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 22 Jul 2008, 06:00 AM
Hello Jo,

You can go through the following help article.
Different edit/insert forms with auto-generated edit form

Regards
Princy.
0
jo
Top achievements
Rank 1
answered on 22 Jul 2008, 01:59 PM
I already read and tried the help article.I'm using GridTemplateColumn. It dosen't have a "read only" property.I need to set visible or enable to false on edit mode.
I tried to access the control from the grid; but it gives null value.

GridEditableItem edititem = (GridEditableItem)e.Item;

RadComboBox RadBox = (RadComboBox)edititem.FindControl("cmbCompanyName");

and i have to do it in  ItemCommand.

thanks!

0
Accepted
Princy
Top achievements
Rank 2
answered on 23 Jul 2008, 11:59 AM
Hi Jo,

Try with the following approach to Enable the ComboBox only in Insert mode.

ASPX:
<telerik:GridTemplateColumn   UniqueName="TemplateCol" HeaderText="TemplateCol"  > 
      <EditItemTemplate> 
         <telerik:RadComboBox ID="RadComboBox2" runat="server" Enabled="false" > 
          </telerik:RadComboBox> 
      </EditItemTemplate> 
 </telerik:GridTemplateColumn> 

CS:
 protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)  
    {  
        if ((e.Item is GridEditFormInsertItem) && (e.Item.OwnerTableView.IsItemInserted))  
        {  
            GridEditFormInsertItem insertitm = (GridEditFormInsertItem)e.Item;  
            RadComboBox combo = (RadComboBox)insertitm["TemplateCol"].FindControl("RadComboBox2");  
            combo.Enabled = true;  
        }  
   } 


Thanks
Princy.
0
jo
Top achievements
Rank 1
answered on 23 Jul 2008, 01:57 PM
Thanks! That works..
Tags
Grid
Asked by
jo
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
jo
Top achievements
Rank 1
Share this question
or