Protected Sub Menu_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadMenuEventArgs) Handles Menu.ItemDataBound Dim menuItem = DirectCast(e.Item.DataItem, dsAdmin.MenuItemRow) If menuItem.MenuItemType = "Separator" Then e.Item.IsSeparator = True End If End SubChartAxisItem xItem = RadChartRiding.PlotArea.XAxis[i];xItem.TextBlock.Text = string.Format("{2}{0}\n{1}", r["firstName"], r["lastName"], (i == d.Rows.Count - 1 ? " - LEADER -\n" : ""));xItem.TextBlock.Appearance.FillStyle.FillType = Telerik.Charting.Styles.FillType.Image;xItem.TextBlock.Appearance.FillStyle.FillSettings.BackgroundImage = string.Format("images/elections/{0}Icon.png", barCode[i]);xItem.TextBlock.Appearance.Dimensions.AutoSize = false;xItem.TextBlock.Appearance.FillStyle.FillSettings.ImageDrawMode = Telerik.Charting.Styles.ImageDrawMode.Align;xItem.TextBlock.Appearance.FillStyle.FillSettings.ImageAlign = Telerik.Charting.Styles.ImageAlignModes.TopLeft;xItem.TextBlock.Appearance.Position.AlignedPosition = Telerik.Charting.Styles.AlignedPositions.TopRight;xItem.TextBlock.Appearance.Dimensions.Height = 75;xItem.TextBlock.Appearance.Dimensions.Width = 330;xItem.TextBlock.Appearance.Dimensions.Paddings.Top = (i == d.Rows.Count - 1 ? 10 : 20);Public Sub Test ()For each item as GridDataItem in RadGrid1.Items Dim i as integer = item.ItemIndex ' (Item.ItemIndex always returns as 0 )Next End SubI have a datagrid that gets filled serverside with he DataSource.
When deleting a item I use the RadGrid1_DeleteCommand event and apply the following code to get the item I have to delete.
void RadGrid1_DeleteCommand(object sender, GridCommandEventArgs e)
{
GridEditableItem item = (GridEditableItem)e.Item;
dynamic DynamicBusinessObject = (item.OwnerTableView.DataSource as IEnumerable<dynamic>).ToList()[item.DataSetIndex];
This normally works great however when the user applies a filter to a column the DataSetIndex returns me the index-number of filtered page, not the corresponding index in the item.OwnerTableView.DataSource.
Much like ItemIndex will do when I’m on another page then page 1 within a grid.
How to get the corresponding item.OwnerTableView.DataSource index-number (or object) of the item.
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm4.aspx.cs" Inherits="Amlak.WebForm4" %><%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title></title></head><body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <div> <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"> <AjaxSettings> <telerik:AjaxSetting AjaxControlID="RadComboBox1"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="CheckBox1" UpdatePanelRenderMode="Inline" /> </UpdatedControls> </telerik:AjaxSetting> </AjaxSettings> </telerik:RadAjaxManager> <telerik:RadComboBox ID="RadComboBox1" runat="server" AutoPostBack="True" AppendDataBoundItems="True" OnSelectedIndexChanged="RadComboBox1_SelectedIndexChanged"> <Items> <telerik:RadComboBoxItem runat="server" Text="1" Value="1" /> <telerik:RadComboBoxItem runat="server" Text="2" Value="2" /> <telerik:RadComboBoxItem runat="server" Text="3" Value="3" /> <telerik:RadComboBoxItem runat="server" Text="4" Value="4" /> </Items> </telerik:RadComboBox> <br /> <br /> <asp:CheckBox ID="CheckBox1" runat="server" AutoPostBack="True" OnCheckedChanged="CheckBox1_CheckedChanged" Text="Check Me" TextAlign="Left" /> <br /> <br /> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> </div> </form></body></html>
My code behind is like this:
using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls; namespace Amlak{ public partial class WebForm4 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void RadComboBox1_SelectedIndexChanged(object sender, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e) { if (RadComboBox1.SelectedItem.Value == "2") { CheckBox1.Checked = true; } else { CheckBox1.Checked = false; } } protected void CheckBox1_CheckedChanged(object sender, EventArgs e) { if (CheckBox1.Checked) { TextBox1.Text = "text"; } else { TextBox1.Text = ""; } } }}
My goals:
I want to force RadComboBox1 to work in AJAX mode
and change the CheckBox1.Checked by defined conditions in code behind.
-> do not want postback for this.
I want to force CheckBox1 to work in PostBack mode and change the TextBox1.text by defined conditions in code behind. -> I want postback for this.
In this scenario -> RadComboBox1 works fine
but I don't know why OnCheckedChanged="CheckBox1_CheckedChanged" does not fire when we change check of CheckBox1! (because we added it as update of RadComboBox1 In RadAjaxManager1).
My questions:
1-Should I add RadComboBox1 as update Of RadComboBox1 or not? However it works fine without adding this.
2-If we add ChechBox1 To RadAjaxManager1 like below:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm4.aspx.cs" Inherits="Amlak.WebForm4" %> <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title></title></head><body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <div> <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"> <AjaxSettings> <telerik:AjaxSetting AjaxControlID="RadComboBox1"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="CheckBox1" UpdatePanelRenderMode="Inline" /> </UpdatedControls> </telerik:AjaxSetting> <telerik:AjaxSetting AjaxControlID="CheckBox1"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="TextBox1" /> </UpdatedControls> </telerik:AjaxSetting> </AjaxSettings> </telerik:RadAjaxManager> <telerik:RadComboBox ID="RadComboBox1" runat="server" AutoPostBack="True" AppendDataBoundItems="True" OnSelectedIndexChanged="RadComboBox1_SelectedIndexChanged"> <Items> <telerik:RadComboBoxItem runat="server" Text="1" Value="1" /> <telerik:RadComboBoxItem runat="server" Text="2" Value="2" /> <telerik:RadComboBoxItem runat="server" Text="3" Value="3" /> <telerik:RadComboBoxItem runat="server" Text="4" Value="4" /> </Items> </telerik:RadComboBox> <br /> <br /> <asp:CheckBox ID="CheckBox1" runat="server" AutoPostBack="True" OnCheckedChanged="CheckBox1_CheckedChanged" Text="Check Me" TextAlign="Left" /> <br /> <br /> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> </div> </form></body></html>
So it works fine in AJAX mode, but I want to force CheckBox1 to work in PostBack!
How can I fix this issue?
3-Should I add TextBox1 as update of RadComboBox1 in RadAjaxManager or not?
Thanks for attention to my question.
best regards