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

Problem Accessing dropdownlist in EditItemTemplateColumn

2 Answers 39 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Nani
Top achievements
Rank 1
Nani asked on 04 Oct 2011, 06:38 PM
I have a EditItemTemplate column with dropdownlist in der...i want to access dropdown list in the code behind but enable access it

Code snipshot

ASPX:
<
telerik:RadGrid ID="RadGrid1" runat="server" AllowAutomaticDeletes="false" AllowAutomaticInserts="True"

AllowSorting="true" AllowAutomaticUpdates="True" AllowPaging="false"

AutoGenerateColumns="False" DataSourceID="ObjectDataSource1" ShowStatusBar="true"

Width="950px" OnItemDataBound= "rgQueue2_OnItemDataBound">

<MasterTableView Width="100%" CommandItemDisplay="TopAndBottom" DataSourceID="ObjectDataSource1"

HorizontalAlign="NotSet" AllowSorting="false" EditMode="InPlace">

<Columns>

<telerik:GridTemplateColumn HeaderText="Source" DataField="SourceName" UniqueName="Source"

 HeaderStyle-Width="250px" ItemStyle-HorizontalAlign="Left">

<ItemTemplate>

<asp:Label ID="lblsource" runat="server"> <%# DataBinder.Eval(Container.DataItem, "SourceName")%> </asp:Label>

</ItemTemplate>

<EditItemTemplate>

<asp:DropDownList ID="ddlsource" runat="server">

</asp:DropDownList>

</EditItemTemplate>

</telerik:GridTemplateColumn>

ASPX.CS:

protected void rgQueue2_OnItemDataBound(object sender, GridItemEventArgs e)

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

GridEditableItem item = e.Item as GridEditableItem;
DropDownList list = item.FindControl("ddlsource") as DropDownList;

 

}

}


Problem is its not entering the if statement even...can anyone suggested me to get through it..!!!
Thanks

2 Answers, 1 is accepted

Sort by
0
Accepted
Andrey
Telerik team
answered on 07 Oct 2011, 01:26 PM
Hi Nani,

I followed  your scenario and everything works as expected on my side. I am attaching the project which I used to test your code.

Also, note that the condition in the if statement is satisfied only when you edit rows or you are inserting new rows. Otherwise the condition is not satisfied and you cannot access the control.

Kind regards,
Andrey
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Nani
Top achievements
Rank 1
answered on 10 Oct 2011, 05:13 PM
Thanku very much  Andrey  i got it
Tags
Grid
Asked by
Nani
Top achievements
Rank 1
Answers by
Andrey
Telerik team
Nani
Top achievements
Rank 1
Share this question
or