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

setting a property for a control within the FormTemplate

3 Answers 66 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Joey
Top achievements
Rank 1
Joey asked on 18 Mar 2009, 09:09 PM

I found the following code on this site but it is never making it into the if statement in red below. I need to set the ConnectionString property on the Types combo box but e.Item.IsInEditMode never returns true for any of the rows. Help!


protected void ConfigurationGrid_ItemDataBound(object sender,
GridItemEventArgs e)

{

if ((e.Item is GridEditFormItem) && (e.Item.IsInEditMode))

{

GridEditableItem edititem = (GridEditableItem)e.Item;

TypeComboBox cmb = CommonUtils.FindControlRecursive<TypeComboBox>(edititem, "Types");

cmb.ConnectionString = Globals.Current.ConnectionString;

}

}

<

 

telerik:RadGrid ID="ConfigurationGrid" runat="server" AllowPaging="True" GridLines="None"

 

 

 

 

 

Skin="Sunset" OnNeedDataSource="ConfigurationGrid_NeedDataSource"

 

 

 

 

 

EnableViewState="false" AllowCustomPaging="True" AutoGenerateColumns="False"

 

 

 

 

 

AllowAutomaticInserts="True" AllowAutomaticUpdates="True" AllowAutomaticDeletes="True"

 

 

 

 

 

OnItemDataBound="ConfigurationGrid_ItemDataBound"

 

 

onitemcommand="ConfigurationGrid_ItemCommand"

 

 

onitemcreated="ConfigurationGrid_ItemCreated">

 

 

 

 

 

<HeaderContextMenu>

 

 

 

 

 

<CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>

 

 

 

 

 

</HeaderContextMenu>

 

 

 

 

 

<MasterTableView EditMode="EditForms" DataKeyNames="ConfigGuid">

 

 

 

 

 

<RowIndicatorColumn>

 

 

 

 

 

<HeaderStyle Width="20px"></HeaderStyle>

 

 

 

 

 

</RowIndicatorColumn>

 

 

 

 

 

<ExpandCollapseColumn>

 

 

 

 

 

<HeaderStyle Width="20px"></HeaderStyle>

 

 

 

 

 

</ExpandCollapseColumn>

 

 

 

 

 

<Columns>

 

 

 

 

 

<telerik:GridEditCommandColumn />

 

 

 

 

 

<telerik:GridClientDeleteColumn />

 

 

 

 

 

<telerik:GridBoundColumn DataField="TypeName" HeaderText="Type" ItemStyle-Wrap="false" />

 

 

 

 

 

<telerik:GridBoundColumn DataField="RegionName" HeaderText="Region" ItemStyle-Wrap="false" />

 

 

 

 

 

<telerik:GridBoundColumn DataField="EnvironmentName" HeaderText="Environment" ItemStyle-Wrap="false" />

 

 

 

 

 

<telerik:GridBoundColumn DataField="ProjectName" HeaderText="Project" ItemStyle-Wrap="false" />

 

 

 

 

 

<telerik:GridHyperLinkColumn DataTextField="Name" DataNavigateUrlFields="ConfigGuid"

 

 

 

 

 

DataNavigateUrlFormatString="~/edit.aspx?ConfigGuid={0}" Target="_blank" HeaderText="Name"

 

 

 

 

 

ItemStyle-Wrap="false" />

 

 

 

 

 

<telerik:GridBoundColumn DataField="Name" HeaderText="Name" ItemStyle-Wrap="false" />

 

 

 

 

 

<telerik:GridBoundColumn DataField="ConfigGuid" HeaderText="Configuration Guid" ItemStyle-Wrap="false" />

 

 

 

 

 

</Columns>

 

 

 

 

 

 

 

 

<

EditFormSettings EditFormType="Template">

<FormTemplate>

<table cellspacing="2" cellpadding="1" width="100%" border="0" rules="none" class="EditForm">

<tr>

<td valign="top">

Type:

</td>

<td>

<SiteInfo:TypeComboBox ID="Types" runat="server" />

<asp:TextBox ID="Type" runat="server" Text='<%# Bind("TypeName") %>' TabIndex="2"

TextMode="MultiLine" Rows="4" Width="600px" MaxLength="255" />

</td>

</tr>
</table>

 

 </FormTemplate>

 

 

 

</EditFormSettings>

 

 

 

</MasterTableView>

 

 

 

<PagerStyle AlwaysVisible="True" Mode="NextPrevNumericAndAdvanced" />

 

 

 

<ClientSettings EnableRowHoverStyle="true">

 

 

 

<Selecting AllowRowSelect="True" />

 

 

 

</ClientSettings>

 

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 19 Mar 2009, 08:03 AM
Hi,

Are using the AdvancedDataBinding technique to bind your grid. If so then the condition should fire when the row is in edit mode.
Take a look at the technique and let me know of any further issues.

Thanks,
Princy

0
Joey
Top achievements
Rank 1
answered on 20 Mar 2009, 09:20 PM
yes i'm using advanced data binding and no the e.Item.IsInEditMode continues to return false. I've updated my first post with the majority of the grid's actuall settings. Is there anything there that I need to change? I just upgraded to the 2009.1 311 version of the telerik controls but the issue persists.
0
Iana Tsolova
Telerik team
answered on 23 Mar 2009, 10:30 AM
Hello Joey,

I prepared a sample project for you following your scenario. Please check it out on your side and let me know if it works as expected and if aI missed something from your logic.

I hope this helps.

Sincerely yours,
Iana
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Joey
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Joey
Top achievements
Rank 1
Iana Tsolova
Telerik team
Share this question
or