I have a radgrid with template column as follows :
<telerik:GridTemplateColumn UniqueName="Priority" DataField="Priority" HeaderText="Priority"
ItemStyle-Width="125px" HeaderStyle-Width="125px">
<ItemTemplate>
<asp:Literal ID="ltlPriority" Text='<%# string.IsNullOrEmpty(Eval("Priority").ToString()) ? 0 : (int)Eval("Priority") %>'
runat="server"></asp:Literal>
</ItemTemplate>
<EditItemTemplate>
<telerik:RadComboBox ID="cmbPriority" runat="server">
</telerik:RadComboBox>
</EditItemTemplate>
</telerik:GridTemplateColumn>
I have to populate the cmbPriority Combobox with numbers equal to total row count.
(if row count is 5, the combobox should show 1,2,3,4,5)
OnItemDatabound this is what I have ::
if (e.Item is GridEditableItem && e.Item.IsInEditMode)
{
GridEditableItem item = (GridEditableItem)e.Item;
object tmpobj = item.FindControl("cmbPriority");
if (tmpobj != null)
{
RadComboBox ddc = tmpobj as RadComboBox;
int nbrofrows = rgProducts.MasterTableView.Items.Count;
List<ProductPriority> priorities = new List<ProductPriority>();
//List<int> priorities = new List<int>();
for (int i = 1; i <= nbrofrows; i++)
{
ProductPriority pp = new ProductPriority();
pp.Priority = i;
priorities.Add(pp);
}
ddc.DataSource = priorities;
ddc.DataTextField = "Priority";
ddc.DataValueField = "Priority";
ddc.DataBind();
}
}
On "Add" command, nbrofrows has the right count.
But, On 'Edit' command, the count is always zero.
Thanks !!!!
Sri
<telerik:GridTemplateColumn UniqueName="Priority" DataField="Priority" HeaderText="Priority"
ItemStyle-Width="125px" HeaderStyle-Width="125px">
<ItemTemplate>
<asp:Literal ID="ltlPriority" Text='<%# string.IsNullOrEmpty(Eval("Priority").ToString()) ? 0 : (int)Eval("Priority") %>'
runat="server"></asp:Literal>
</ItemTemplate>
<EditItemTemplate>
<telerik:RadComboBox ID="cmbPriority" runat="server">
</telerik:RadComboBox>
</EditItemTemplate>
</telerik:GridTemplateColumn>
I have to populate the cmbPriority Combobox with numbers equal to total row count.
(if row count is 5, the combobox should show 1,2,3,4,5)
OnItemDatabound this is what I have ::
if (e.Item is GridEditableItem && e.Item.IsInEditMode)
{
GridEditableItem item = (GridEditableItem)e.Item;
object tmpobj = item.FindControl("cmbPriority");
if (tmpobj != null)
{
RadComboBox ddc = tmpobj as RadComboBox;
int nbrofrows = rgProducts.MasterTableView.Items.Count;
List<ProductPriority> priorities = new List<ProductPriority>();
//List<int> priorities = new List<int>();
for (int i = 1; i <= nbrofrows; i++)
{
ProductPriority pp = new ProductPriority();
pp.Priority = i;
priorities.Add(pp);
}
ddc.DataSource = priorities;
ddc.DataTextField = "Priority";
ddc.DataValueField = "Priority";
ddc.DataBind();
}
}
On "Add" command, nbrofrows has the right count.
But, On 'Edit' command, the count is always zero.
Thanks !!!!
Sri