Hi All,
This is my first time using Telerik in ASP.Net project.
In my project, I have used TelerikGrid for displaying and editing data. Please refer to code below:
<telerik:RadGrid ID="rgAddData" GridLines="None" runat="server" AllowAutomaticDeletes="True"
AllowAutomaticInserts="True" AllowAutomaticUpdates="True" AllowPaging="True" PageSize="10" EnableLinqExpressions="false"
AutoGenerateColumns="False" OnItemUpdated="rgAddData_ItemUpdated" OnItemDeleted="rgAddData_ItemDeleted"
OnItemInserted="rgAddData_ItemInserted" OnItemCommand="rgAddData_ItemCommand">
<PagerStyle Mode="NextPrevAndNumeric" />
<MasterTableView Width="100%" EditMode="InPlace"
CommandItemSettings-AddNewRecordImageUrl="../images/img_Add.png"
CommandItemSettings-AddNewRecordText = "Add Data"
CommandItemSettings-RefreshText = ""
CommandItemSettings-RefreshImageUrl="../images/img_Blank.png"
ShowHeadersWhenNoRecords="true" ShowHeader="true"
CommandItemDisplay="Top" DataKeyNames="DataID"
AutoGenerateColumns="False"
HeaderStyle-Font-Bold="true">
<Columns>
<telerik:GridDropDownColumn HeaderText="Client" UniqueName="Client" ColumnEditorID="DropDownStyle">
</telerik:GridDropDownColumn>
<telerik:GridTemplateColumn HeaderText="Age" UniqueName="Age">
<ItemTemplate>
<asp:DropDownList ID="ddlAge" runat="server" Style="width:110px;"></asp:DropDownList>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn">
</telerik:GridEditCommandColumn>
<telerik:GridButtonColumn ConfirmText="Delete this data?" ConfirmDialogType="RadWindow"
ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" Text="Delete"
UniqueName="DeleteColumn">
<ItemStyle HorizontalAlign="Center" CssClass="addCassetteImageButton" />
</telerik:GridButtonColumn>
</Columns>
<EditFormSettings ColumnNumber="2" CaptionDataField="DataID" CaptionFormatString="Edit cassette {0}"> </EditFormSettings>
</MasterTableView>
</telerik:RadGrid>
<telerik:GridDropDownListColumnEditor ID="DropDownStyle" runat="server" DropDownStyle-Width="110px" />
<telerik:RadWindowManager ID="RadWindowManager1" runat="server"></telerik:RadWindowManager>
---------------------------------------------------------------------------------------------------------------
I have an asp:dropdownlist control declared under the ItemTemplate. This drop down list will then bind with the data return from the file from another c# project. Below is the code:
public static List<KeyValuePair<int, string>> GetAgeList()
{
List<KeyValuePair<int, string>> ageList = new List<KeyValuePair<int, string>>();
for (int i = 0; i < 10; i++)
{
ageList.Add(new KeyValuePair<int, string>(i, i + " yrs"));
}
return ageList;
}
--------------------------------------------------------------------------
Then in my C# code, I want to use findControl to get the "ddlAge" in order to bind with the return values from the above codes.
Below is my code:
protected void rgAddCassette_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
{
((DropDownList)e.Item.FindControl("ddlAge")).DataSource = Services.ListOfValues.GetAgeList();
((DropDownList)e.Item.FindControl("ddlAge")).DataBind();
}
---------------------------------------------
However, I got this error cannot find the control.
Could anyone please do help me on how should I use the FindControl to get the asp dropdownlist control that I declared under ItemTemplate?
In my project, there are 3 RadGrid with similar settings, where I've added the asp drop down list under itemtemplate and bind with the value list return from other project.
Thanks for the help!
This is my first time using Telerik in ASP.Net project.
In my project, I have used TelerikGrid for displaying and editing data. Please refer to code below:
<telerik:RadGrid ID="rgAddData" GridLines="None" runat="server" AllowAutomaticDeletes="True"
AllowAutomaticInserts="True" AllowAutomaticUpdates="True" AllowPaging="True" PageSize="10" EnableLinqExpressions="false"
AutoGenerateColumns="False" OnItemUpdated="rgAddData_ItemUpdated" OnItemDeleted="rgAddData_ItemDeleted"
OnItemInserted="rgAddData_ItemInserted" OnItemCommand="rgAddData_ItemCommand">
<PagerStyle Mode="NextPrevAndNumeric" />
<MasterTableView Width="100%" EditMode="InPlace"
CommandItemSettings-AddNewRecordImageUrl="../images/img_Add.png"
CommandItemSettings-AddNewRecordText = "Add Data"
CommandItemSettings-RefreshText = ""
CommandItemSettings-RefreshImageUrl="../images/img_Blank.png"
ShowHeadersWhenNoRecords="true" ShowHeader="true"
CommandItemDisplay="Top" DataKeyNames="DataID"
AutoGenerateColumns="False"
HeaderStyle-Font-Bold="true">
<Columns>
<telerik:GridDropDownColumn HeaderText="Client" UniqueName="Client" ColumnEditorID="DropDownStyle">
</telerik:GridDropDownColumn>
<telerik:GridTemplateColumn HeaderText="Age" UniqueName="Age">
<ItemTemplate>
<asp:DropDownList ID="ddlAge" runat="server" Style="width:110px;"></asp:DropDownList>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn">
</telerik:GridEditCommandColumn>
<telerik:GridButtonColumn ConfirmText="Delete this data?" ConfirmDialogType="RadWindow"
ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" Text="Delete"
UniqueName="DeleteColumn">
<ItemStyle HorizontalAlign="Center" CssClass="addCassetteImageButton" />
</telerik:GridButtonColumn>
</Columns>
<EditFormSettings ColumnNumber="2" CaptionDataField="DataID" CaptionFormatString="Edit cassette {0}"> </EditFormSettings>
</MasterTableView>
</telerik:RadGrid>
<telerik:GridDropDownListColumnEditor ID="DropDownStyle" runat="server" DropDownStyle-Width="110px" />
<telerik:RadWindowManager ID="RadWindowManager1" runat="server"></telerik:RadWindowManager>
---------------------------------------------------------------------------------------------------------------
I have an asp:dropdownlist control declared under the ItemTemplate. This drop down list will then bind with the data return from the file from another c# project. Below is the code:
public static List<KeyValuePair<int, string>> GetAgeList()
{
List<KeyValuePair<int, string>> ageList = new List<KeyValuePair<int, string>>();
for (int i = 0; i < 10; i++)
{
ageList.Add(new KeyValuePair<int, string>(i, i + " yrs"));
}
return ageList;
}
--------------------------------------------------------------------------
Then in my C# code, I want to use findControl to get the "ddlAge" in order to bind with the return values from the above codes.
Below is my code:
protected void rgAddCassette_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
{
((DropDownList)e.Item.FindControl("ddlAge")).DataSource = Services.ListOfValues.GetAgeList();
((DropDownList)e.Item.FindControl("ddlAge")).DataBind();
}
---------------------------------------------
However, I got this error cannot find the control.
Could anyone please do help me on how should I use the FindControl to get the asp dropdownlist control that I declared under ItemTemplate?
In my project, there are 3 RadGrid with similar settings, where I've added the asp drop down list under itemtemplate and bind with the value list return from other project.
Thanks for the help!