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

Change DataSource of GridDropDownColumn in Insert

9 Answers 144 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Chaya Carmi
Top achievements
Rank 1
Chaya Carmi asked on 08 Mar 2010, 09:47 AM

Hello,

I need to change dataSource in DropDownList(ddl1) in RadGrid when the client choosed value in other dropDownList(ddl2) in RadGrid.

In ItemCreated I registered to event selectIndexChanged of ddl2

And in the event I changed the dataSource of ddl1(as I saw on your instructions)  

Here's the code:

protected void Grid_ny_ParticipationStatus_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)

    {

        if (e.Item is Telerik.Web.UI.GridEditableItem && e.Item.IsInEditMode || e.Item is Telerik.Web.UI.GridEditableItem && e.Item.OwnerTableView.IsItemInserted)

        {

            ddlActive = (e.Item as Telerik.Web.UI.GridEditableItem)["iActiveId"].Controls[0] as Telerik.Web.UI.RadComboBox;

            if (ddlActive != null)

            {

                ddlActive.AutoPostBack = true;

                ddlActive.SelectedIndexChanged += new Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventHandler(ddlActive_SelectedIndexChanged);

                               {

                     }

         }

protected void ddlActive_SelectedIndexChanged(object sender, System.EventArgs e)

    {

        int active;

        int.TryParse(ddlActive.SelectedValue, out active);

        Telerik.Web.UI.GridEditableItem editableItem = (sender as Telerik.Web.UI.RadComboBox).NamingContainer as Telerik.Web.UI.GridEditableItem;

        Telerik.Web.UI.RadComboBox ddl = editableItem["iParticipationStatusId"].Controls[0] as Telerik.Web.UI.RadComboBox;

        ddl.DataSource = codeTablesMng.GetCodeTable("tbl_code_ParticipationStatus", "iActiveId", active);

        ddl.DataBind();

         }

The problem that in update it's work and in Insert it's not work.

Please your help.

Thank you.

Chaya



9 Answers, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 10 Mar 2010, 01:46 PM
Hi Chaya,

Try with the following if statement instead:

if (e.Item is Telerik.Web.UI.GridEditableItem && e.Item.IsInEditMode)
{
 
}

This will evaluate to true both for the edit and insert form.

Regards,
Veli
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Chaya Carmi
Top achievements
Rank 1
answered on 11 May 2010, 10:31 AM
I tried it . but it's not work.
in update it's working, but in Insert it's not working
0
Veli
Telerik team
answered on 11 May 2010, 01:41 PM
Hello Chaya,

Can you post some sample code from your grid definition (both markup and codebehind) we can examine?

Sincerely yours,
Veli
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
lea ginsberger
Top achievements
Rank 1
answered on 14 Jun 2010, 10:14 AM
aspx file


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Yeshivas.aspx.cs" Inherits="Pages_Lists_Yeshivas" %>

<%@ Register TagPrefix="UC1" TagName="headerUC" Src="~/UC/headerUC.ascx" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

<%@ Register Assembly="Infra" Namespace="Infra.UI" TagPrefix="my" %>

<!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>

     <link href="../../Stylesheets/Global.css" rel="stylesheet" type="text/css" />

 

    <script src="../../JS/Grid.js" type="text/javascript"></script>

</head>

<body>

    <form id="form1" runat="server">

    <UC1:headerUC ID="HeaderUC1" runat="server" />

    <font class="FirstHeaderCenter">ישיבות </font>

    <my:RadEditGrid ID="Grid_gen_Yeshiva" runat="server" AutoGenerateColumns="False" GridLines="None"

    SpInsertName="PRG_gen_Yeshiva_INS" SpUpdateName="PRG_gen_Yeshiva_UPD" SpSelectName="PRG_gen_Yeshiva_SLCT"

        AllowPaging="True" PageSize="15" AllowSorting="True" Font-Strikeout="False"  OnItemDataBound="Grid_gen_Yeshiva_ItemDataBound" OnItemCreated="Grid_gen_Yeshiva_ItemCreated"

        AllowFilteringByColumn="True" OnInsertCommand="Grid_gen_Yeshiva_InsertCommand" OnUpdateCommand="Grid_gen_Yeshiva_UpdateCommand" OnItemCommand="Grid_gen_Yeshiva_ItemCommand"

         OnNeedDataSource="Grid_gen_Yeshiva_NeedDataSource" >

        <MasterTableView DataKeyNames="iYeshivaId" AllowMultiColumnSorting="True" CommandItemDisplay="Top"

            EditMode="PopUp" Width="100%" >

            <CommandItemTemplate>

                <asp:LinkButton runat="server" ID="AddNew" Text="הוסף " CommandName="InitInsert">

                    <asp:Image ID="imgAdd" runat="server" ImageUrl="~/Images/Icons/New.png" />

                </asp:LinkButton>

            </CommandItemTemplate>

            <PagerStyle AlwaysVisible="true" PageSizeLabelText="שורות " FirstPageText="ראשון "

                LastPageText="אחרון " NextPageText="הבא " PrevPageText="קודם " PagerTextFormat="Change page: {4}  דף {0} מתוך {1}, רשומות {2} עד {3} מתוך {5}" />

                    <DetailTables>

                        <my:GridTableView Name="Grid_CustomerInYeshiva" Caption="לקוחות בישיבה " CommandItemDisplay="top"

                            DataKeyNames="iPersonId,iYeshivaId" EditMode="PopUp" Width="100%"

                            AllowPaging="false" AllowFilteringByColumn="false" Dir="rtl">

                            <CommandItemTemplate>

                            </CommandItemTemplate>

                            <ParentTableRelation>

                                <telerik:GridRelationFields DetailKeyField="iYeshivaId" MasterKeyField="iYeshivaId" />

                            </ParentTableRelation>

                            <Columns>

                                <telerik:GridEditCommandColumn UniqueName="EditCommandColumn" HeaderText="ערוך " EditText="ערוך "

                                    UpdateText="שמור " CancelText="בטל " InsertText="הוסף " ButtonType="ImageButton">

                                </telerik:GridEditCommandColumn>

                                <telerik:GridBoundColumn UniqueName="iYeshivaId" DataField="iYeshivaId" HeaderText="iYeshivaId"

                                    Visible="false" ReadOnly="true">

                                </telerik:GridBoundColumn>

                                <telerik:GridBoundColumn UniqueName="iPersonId" DataField="iPersonId" HeaderText="iPersonId"

                                    Visible="false" ReadOnly="true">

                                </telerik:GridBoundColumn>

                                <telerik:GridBoundColumn UniqueName="nvName" DataField="nvName"

                                 HeaderText="שם לקוח " ReadOnly="true">

                                </telerik:GridBoundColumn>

                              <telerik:GridDateTimeColumn UniqueName="dtEntryDate" DataField="dtEntryDate" HeaderText=" תאריך כניסה "

                              DataFormatString="{0:dd/MM/yyyy}"  AutoPostBackOnFilter="true" ShowFilterIcon="false" CurrentFilterFunction="Contains" ReadOnly="true" >

                            </telerik:GridDateTimeColumn>

                            <telerik:GridDateTimeColumn UniqueName="dtLeavingDate" DataField="dtLeavingDate" HeaderText=" תאריך עזיבה "

                              DataFormatString="{0:dd/MM/yyyy}"  AutoPostBackOnFilter="true" ShowFilterIcon="false" CurrentFilterFunction="Contains" Visible="false"  >

                            </telerik:GridDateTimeColumn>

                             </Columns>

                            <EditFormSettings CaptionFormatString="נא הזן פרטי לקוח בישיבה " EditColumn-CancelText="בטל "

                                EditColumn-InsertText="הוסף " EditColumn-EditText="ערוך " EditColumn-UpdateText="עדכן ">

                                <PopUpSettings Modal="true" />

                                <EditColumn ButtonType="ImageButton" />

                            </EditFormSettings>

                        </my:GridTableView>

                    </DetailTables>

            <Columns>

                <telerik:GridEditCommandColumn UniqueName="EditCommandColumn" HeaderText="ערוך " EditText="ערוך "

                    UpdateText="שמור " CancelText="בטל " InsertText="הוסף " ButtonType="ImageButton">

                </telerik:GridEditCommandColumn>

                <telerik:GridBoundColumn UniqueName="iYeshivaId" DataField="iYeshivaId" HeaderText="iYeshivaId"

                    Visible="false" ReadOnly="true">

                </telerik:GridBoundColumn>

                <telerik:GridBoundColumn UniqueName="nvYeshivaName" DataField="nvYeshivaName" HeaderText="שם ישיבה "

                    AutoPostBackOnFilter="true" ShowFilterIcon="false" CurrentFilterFunction="Contains">

                </telerik:GridBoundColumn>

                <telerik:GridBoundColumn UniqueName="iAddressId_UPD" DataField="iAddressId" HeaderText="iAddressId"

                    Visible="false" ReadOnly="true">

                </telerik:GridBoundColumn>

                <telerik:GridBoundColumn UniqueName="nvCitySynonymName" DataField="nvCitySynonymName"

                    HeaderText="עיר " AutoPostBackOnFilter="true" ShowFilterIcon="false" CurrentFilterFunction="Contains"

                    ReadOnly="true">

                </telerik:GridBoundColumn>

                <telerik:GridDropDownColumn UniqueName="iCityId" ListDataMember="v_add_City" SortExpression="nvCitySynonymName"

                    ListTextField="nvCitySynonymName" ListValueField="iCityId" HeaderText="עיר " DataField="iCityId"

                    EmptyListItemText=" " Visible="false" DropDownControlType="RadComboBox">

                </telerik:GridDropDownColumn>

                 <telerik:GridDropDownColumn UniqueName="iStreetId" ListDataMember="t_add_Streets"

                    SortExpression="nvStreetSynonymName" ListTextField="nvStreetSynonymName" ListValueField="iStreetId"

                    HeaderText="רחוב "  EmptyListItemText=" " Visible="false">

                </telerik:GridDropDownColumn>

              

 


<telerik:GridBoundColumn EditFormColumnIndex="1" UniqueName="nvStreetSynonymName" DataField="nvStreetSynonymName"

                    HeaderText="רחוב " Visible="false">

                </telerik:GridBoundColumn>

                 <telerik:GridBoundColumn UniqueName="nvYeshivaTypeName" DataField="nvYeshivaTypeName"

                    HeaderText="סוג ישיבה " ReadOnly="true" AutoPostBackOnFilter="true" ShowFilterIcon="false"

                    CurrentFilterFunction="Contains" >

                </telerik:GridBoundColumn>

                <telerik:GridDropDownColumn UniqueName="iYeshivaTypeId"

                    ListDataMember="t_code_YeshivaType" SortExpression="nvTypeName" ListTextField="nvYeshivaTypeName"

                    ListValueField="iYeshivaTypeId" HeaderText="סוג ישיבה " DataField="iYeshivaTypeId"

                    EmptyListItemText=" " Visible="false" DropDownControlType="RadComboBox" >

                </telerik:GridDropDownColumn>

                <telerik:GridBoundColumn  UniqueName="nvYeshivaManager" DataField="nvYeshivaManager"

                    HeaderText="ראש הישיבה "   AutoPostBackOnFilter="true"

                    ShowFilterIcon="false" CurrentFilterFunction="Contains">

                </telerik:GridBoundColumn>

                <telerik:GridBoundColumn  UniqueName="nvPhoneNumber" DataField="nvPhoneNumber" MaxLength="11"

                    HeaderText="טלפון "   AutoPostBackOnFilter="true"

                    ShowFilterIcon="false" CurrentFilterFunction="Contains">

                </telerik:GridBoundColumn>

                 <telerik:GridBoundColumn  UniqueName="nvContact" DataField="nvContact"

                    HeaderText="איש קשר "   AutoPostBackOnFilter="true"

                    ShowFilterIcon="false" CurrentFilterFunction="Contains">

                </telerik:GridBoundColumn>

                <telerik:GridBoundColumn  UniqueName="nvContactPhoneNumber" DataField="nvContactPhoneNumber" MaxLength="11"

                    HeaderText="טלפון איש קשר "  AutoPostBackOnFilter="true"

                    ShowFilterIcon="false" CurrentFilterFunction="Contains">

                </telerik:GridBoundColumn>

                <telerik:GridBoundColumn UniqueName="nvYeshivaStatusName" DataField="nvYeshivaStatusName"

                    HeaderText="סטטוס " ReadOnly="true" AutoPostBackOnFilter="true" ShowFilterIcon="false"

                    CurrentFilterFunction="Contains">

                </telerik:GridBoundColumn>

                <telerik:GridDropDownColumn UniqueName="iYeshivaStatusId"

                    ListDataMember="t_code_YeshivaStatus" SortExpression="nvStatusName" ListTextField="nvYeshivaStatusName"

                    ListValueField="iYeshivaStatusId" HeaderText="סטטוס " DataField="iYeshivaStatusId"

                    EmptyListItemText=" " Visible="false" DropDownControlType="RadComboBox">

                </telerik:GridDropDownColumn>

                 <telerik:GridBoundColumn  UniqueName="nvComment" DataField="nvComment"

                    HeaderText="הערות "  AutoPostBackOnFilter="true"

                    ShowFilterIcon="false" CurrentFilterFunction="Contains">

                </telerik:GridBoundColumn>  

                 <telerik:GridBoundColumn UniqueName="numCustomer" DataField="numCustomer" HeaderText="מספר נערים " ReadOnly="true"

                    AutoPostBackOnFilter="true" ShowFilterIcon="false" CurrentFilterFunction="Contains" >

                </telerik:GridBoundColumn>         

            </Columns>

         <EditFormSettings  CaptionFormatString="נא הזן פרטי ישיבה " EditColumn-InsertText="הוסף " EditColumn-UpdateText="עדכן " EditColumn-CancelText="בטל "

                PopUpSettings-Modal="true" PopUpSettings-Width="250px">

                <FormTableStyle GridLines="None" CellSpacing="0" CellPadding="2"></FormTableStyle>

                <EditColumn ButtonType="ImageButton" />

            </EditFormSettings>  

        </MasterTableView>

        <SelectedItemStyle BackColor="#99CCFF" BorderColor="#CCFFFF" />

         <ClientSettings AllowDragToGroup="True">

            <ClientEvents  OnPopUpShowing="PopUpShowing" />

        </ClientSettings>

    </my:RadEditGrid>

    </form>

</body>

</html>

 


codebehind

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Data;

using Yedidim;

using Telerik.Web.UI;

using Infra;

 

public partial class Pages_Lists_Yeshivas : System.Web.UI.Page

{

    CodeTablesMng codeTablesMng;

    public Yedidim.commandName  itemCommandName;

    RadComboBox ddlCity = new Telerik.Web.UI.RadComboBox();

    public DataSet YeshivasData

    {

        get

        {

            DataSet obj = SessionMng.YeshivasData;

            if (obj != null)

                return (DataSet)obj;

            DataSet dsYeshivas = Grid_gen_Yeshiva.Select();

            dsYeshivas.Tables.Add(codeTablesMng.GetCodeTable("t_code_YeshivaType"));

            dsYeshivas.Tables.Add(codeTablesMng.GetCodeTable("t_code_YeshivaStatus"));

            dsYeshivas.Tables.Add(codeTablesMng.GetCodeTable("v_add_City"));

            dsYeshivas.Tables.Add(codeTablesMng.GetCodeTable("t_add_Streets", "iCityId", 0));

            SessionMng.YeshivasData = dsYeshivas;

            obj = SessionMng.YeshivasData;

            return (DataSet)obj;

        }

    }

 

    protected void Page_Load(object sender, EventArgs e)

    {

        HeaderUC1.LoadHeaderUC();//שורת קוד זו חיבת להופיע ראשונה בפונקציה

        HeaderUC1.AddToAjax("Grid_gen_Yeshiva", true);

 

        string myScript = "<script language='javascript'>setScrollHeight('Grid_gen_Yeshiva',10);</script>";

        ScriptManager.RegisterStartupScript(this, this.GetType(), "MyScript", myScript, false);

    }

    protected void Page_PreRender(object sender, System.EventArgs e)

    {

        if (!this.IsPostBack)

        {

            this.Grid_gen_Yeshiva.AllowMultiRowEdit = true;

            this.Grid_gen_Yeshiva.MasterTableView.Rebind();

        }

    }

    protected void Grid_gen_Yeshiva_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)

    {

        DataSet dsMain = this.YeshivasData;

        DataSet dsCustomerInYeshiva = new DataSet();

 

        //השמה לגריד של ישיבות

        this.Grid_gen_Yeshiva.DataSource = dsMain;

        //השמה לגריד של לקוחות בישיבה

        dsCustomerInYeshiva.Tables.Add(dsMain.Tables[1].Copy());

        dsCustomerInYeshiva.Tables.Add(dsMain.Tables[2].Copy());

        Grid_gen_Yeshiva.MasterTableView.DetailTables[0].DataSource = dsCustomerInYeshiva;

    }

 

    protected void Page_Init(object sender, EventArgs e)

    {

        if ((SessionMng.CurrentUser as Yedidim.User) != null)

        {

            SessionMng.YeshivasData = null;

            if (Application["dsCodeTables"] != null)

            {

                codeTablesMng = Application["dsCodeTables"] as CodeTablesMng;

            }

        }

    }

  

    protected void Grid_gen_Yeshiva_InsertCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)

    {

        Grid_gen_Yeshiva.Insert(source, e);

        SessionMng.YeshivasData = null;

        DataSet dsMain = this.YeshivasData;

        DataSet dsCustomerInYeshiva = new DataSet();

 

        //השמה לגריד של ישיבות

        this.Grid_gen_Yeshiva.DataSource = dsMain;

        //השמה לגריד של לקוחות בישיבה

        dsCustomerInYeshiva.Tables.Add(dsMain.Tables[1].Copy());

        dsCustomerInYeshiva.Tables.Add(dsMain.Tables[2].Copy());

        Grid_gen_Yeshiva.MasterTableView.DetailTables[0].DataSource = dsCustomerInYeshiva;   

    }

    protected void Grid_gen_Yeshiva_UpdateCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)

    {

        if (e.Item.OwnerTableView.Name == string.Empty)

            Grid_gen_Yeshiva.SpUpdateName="PRG_gen_Yeshiva_UPD";

        else

            Grid_gen_Yeshiva.SpUpdateName="gen_CustomerInYeshiva_UPD";

            Grid_gen_Yeshiva.Update(source, e);

            SessionMng.YeshivasData = null;

            DataSet dsMain = this.YeshivasData;

            DataSet dsCustomerInYeshiva = new DataSet();

 

            //השמה לגריד של ישיבות

            this.Grid_gen_Yeshiva.DataSource = dsMain;

            //השמה לגריד של לקוחות בישיבה

            dsCustomerInYeshiva.Tables.Add(dsMain.Tables[1].Copy());

            dsCustomerInYeshiva.Tables.Add(dsMain.Tables[2].Copy());

            Grid_gen_Yeshiva.MasterTableView.DetailTables[0].DataSource = dsCustomerInYeshiva;      

      

    }

                 

       

   

    protected void Grid_gen_Yeshiva_ItemDataBound(object sender, GridItemEventArgs e)

    {

        if (e.Item.OwnerTableView.Name == string.Empty)

        {

            if (itemCommandName == Yedidim.commandName.InitInsert)

            {

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

                {

 

                    RadComboBox list = (e.Item as GridEditableItem)["iYeshivaStatusId"].Controls[0] as RadComboBox;

                    list.SelectedValue = "1";

                    RadComboBox list2 = (e.Item as GridEditableItem)["iCityId"].Controls[0] as RadComboBox;

                    list2.MarkFirstMatch = true;

                    RadComboBox list3 = (e.Item as GridEditableItem)["iStreetId"].Controls[0] as RadComboBox;

                    list3.MarkFirstMatch = true;

                    list3.DataSource = codeTablesMng.GetCodeTable("t_add_Streets", "iCityId", Convert.ToInt32(list2.SelectedValue));

                   

 

                }

            }

        }

    }

 

    protected void Grid_gen_Yeshiva_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)

    {

        if (e.Item.OwnerTableView.Name == string.Empty)

            if (e.CommandName == Yedidim.commandName.InitInsert.ToString())

                itemCommandName = Yedidim.commandName.InitInsert;

 

    }

 

    protected void Grid_gen_Yeshiva_ItemCreated(object sender, GridItemEventArgs e)

    {

        if (e.Item.OwnerTableView.Name == string.Empty)

        {

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

            {

                string ErrorMsg = "* חובה להזנה ";

                //שדה שם ישיבה חובה להזנה

                Infra.UI.RequiredFieldValidator validatornvYeshivaName = Validator.CreateTextBoxValidator(e, "nvYeshivaName", ErrorMsg);

                //שדה עיר חובה להזנה

                Infra.UI.RequiredFieldValidator validatorCity = Validator.CreateComboBoxValidator(e, "iCityId", ErrorMsg);

            }

        }

 

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

        {

            ddlCity = (e.Item as GridEditableItem)["iCityId"].Controls[0] as RadComboBox;

            if (ddlCity != null)

            {

                ddlCity.AutoPostBack = true;

                ddlCity.SelectedIndexChanged += new RadComboBoxSelectedIndexChangedEventHandler(ddlCity_SelectedIndexChanged);

            }

        }

    }

 

 

    protected void ddlCity_SelectedIndexChanged(object sender, System.EventArgs e)

    {

        //הצגת הרחובות בקומבו בהתאם לעיר שנבחרה

        int city;

        int.TryParse(ddlCity.SelectedValue, out city);

        GridEditableItem editableItem = (sender as Telerik.Web.UI.RadComboBox).NamingContainer as GridEditableItem;

        RadComboBox ddl = editableItem["iStreetId"].Controls[0] as RadComboBox;

        ddl.DataSource = codeTablesMng.GetCodeTable("t_add_Streets", "iCityId", city);

        ddl.DataBind();

      

    }

}

 


thank you for your help!


0
Veli
Telerik team
answered on 15 Jun 2010, 07:14 AM
Hello lea,

Try with the following check:

if ((e.Item is Telerik.Web.UI.GridEditFormItem || e.Item is Telerik.Web.UI.GridEditFormInsertItem) && e.Item.IsInEditMode)
{
  
}

Other than that, the code seems OK.

Sincerely yours,
Veli
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
lea ginsberger
Top achievements
Rank 1
answered on 15 Jun 2010, 08:59 AM

We tried to do by this code.
But only in updating and it works ant in inserting no.

the code:

protected void Grid_gen_Yeshiva_ItemCreated(object sender, GridItemEventArgs e)

    {

        if (e.Item.OwnerTableView.Name == string.Empty)

        {

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

            {

                string ErrorMsg = "* חובה להזנה ";

                //שדה שם ישיבה חובה להזנה

                Infra.UI.RequiredFieldValidator validatornvYeshivaName = Validator.CreateTextBoxValidator(e, "nvYeshivaName", ErrorMsg);

                //שדה עיר חובה להזנה

                Infra.UI.RequiredFieldValidator validatorCity = Validator.CreateComboBoxValidator(e, "iCityId", ErrorMsg);

            }

        }

 

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

        {

            ddlCity = (e.Item as GridEditableItem)["iCityId"].Controls[0] as RadComboBox;

            if (ddlCity != null)

            {

                ddlCity.AutoPostBack = true;

                ddlCity.SelectedIndexChanged += new RadComboBoxSelectedIndexChangedEventHandler(ddlCity_SelectedIndexChanged);

            }

        }

    }

 


0
Veli
Telerik team
answered on 16 Jun 2010, 11:18 AM
Hello lea,

We cannot identify the cause of this misbehavior by the sample code you provided. The code seems fine and the combo in the edit form should autopostback both for edited and inserted items.

Consider updating Telerik RadControls for ASP.NET AJAX to the latest version and see if it makes any difference. If the problem persists, we recommend you open a regular support ticket where you can send us a simplified test project we can debug locally. This will help us better identify the cause of this issue and advise you further.

Kind regards,
Veli
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
lea ginsberger
Top achievements
Rank 1
answered on 22 Jun 2010, 07:50 AM
 test project
aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> 
 
<%@ 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>  
 
    <script src="JScript.js" type="text/javascript"></script> 
</head> 
<body> 
    <form id="form1" runat="server">  
    <asp:ScriptManager ID="ScriptManager1" runat="server">  
    </asp:ScriptManager> 
    <telerik:RadGrid ID="Grid_CustomerInSite" runat="server" AutoGenerateColumns="False" 
        GridLines="None" AllowPaging="True" PageSize="15" AllowSorting="True" Font-Strikeout="False" 
        AllowFilteringByColumn="true" OnInsertCommand="Grid_CustomerInSite_InsertCommand" 
        OnNeedDataSource="Grid_CustomerInSite_NeedDataSource" OnUpdateCommand="Grid_CustomerInSite_UpdateCommand" 
        OnItemCreated="Grid_CustomerInSite_ItemCreated">  
        <MasterTableView DataKeyNames="" AllowMultiColumnSorting="True" AllowAutomaticInserts="true" 
            AllowAutomaticUpdates="true" CommandItemDisplay="Top" EditMode="PopUp" Width="100%">  
            <CommandItemTemplate> 
                <asp:LinkButton runat="server" ID="AddNew" Text="הוסף" CommandName="InitInsert">  
                    <asp:Image ID="imgAdd" runat="server" ImageUrl="" /> 
                </asp:LinkButton> 
            </CommandItemTemplate> 
            <PagerStyle AlwaysVisible="true" PageSizeLabelText="שורות" FirstPageText="ראשון" 
                LastPageText="אחרון" NextPageText="הבא" PrevPageText="קודם" PagerTextFormat="Change page: {4}  דף {0} מתוך {1}, רשומות {2} עד {3} מתוך {5}" /> 
            <Columns> 
                <telerik:GridEditCommandColumn UniqueName="EditCommandColumn" HeaderText="ערוך" EditText="ערוך" 
                    UpdateText="שמור" CancelText="בטל" InsertText="הוסף" ButtonType="ImageButton">  
                </telerik:GridEditCommandColumn> 
                <telerik:GridBoundColumn UniqueName="nvOrganizationName" DataField="nvOrganizationName" 
                    HeaderText="ארגון" ReadOnly="true" AutoPostBackOnFilter="true" ShowFilterIcon="false" 
                    CurrentFilterFunction="Contains">  
                </telerik:GridBoundColumn> 
                <telerik:GridDropDownColumn UniqueName="iOrganizationId" ListDataMember="Table2" 
                    SortExpression="nvOrganizationName" ListTextField="nvOrganizationName" ListValueField="iOrganizationId" 
                    HeaderText="ארגון" DataField="iOrganizationId" EmptyListItemText=" " Visible="false">  
                </telerik:GridDropDownColumn> 
                <telerik:GridBoundColumn UniqueName="nvProjectName" DataField="nvProjectName" HeaderText="פרויקט" 
                    ReadOnly="true" AutoPostBackOnFilter="true" ShowFilterIcon="false" CurrentFilterFunction="Contains">  
                </telerik:GridBoundColumn> 
                <telerik:GridDropDownColumn UniqueName="iProjectId" ListDataMember="Table1" SortExpression="nvProjectName" 
                    ListTextField="nvProjectName" ListValueField="iProjectId" HeaderText="פרויקט" 
                    DataField="iProjectId" EmptyListItemText=" " Visible="false">  
                </telerik:GridDropDownColumn> 
            </Columns> 
            <EditFormSettings ColumnNumber="1" CaptionFormatString="נא הזן פרטי לקוח " PopUpSettings-Modal="true" 
                PopUpSettings-Width="550px" EditColumn-CancelText="בטל" EditColumn-InsertText="הוסף" 
                EditColumn-EditText="ערוך" EditColumn-UpdateText="עדכן">  
                <FormTableStyle GridLines="None" CellSpacing="0" CellPadding="1"></FormTableStyle> 
                <FormStyle Width="100%" BackColor="#eef2ea"></FormStyle> 
                <EditColumn ButtonType="ImageButton" /> 
            </EditFormSettings> 
        </MasterTableView> 
        <ClientSettings> 
            <ClientEvents OnPopUpShowing="PopUpShowing" /> 
        </ClientSettings> 
    </telerik:RadGrid> 
    </form> 
</body> 
</html> 
  

aspx.cs:

using System;  
using System.Collections.Generic;  
using System.Linq;  
using System.Web;  
using System.Web.UI;  
using System.Web.UI.WebControls;  
using Telerik.Web.UI;  
using System.Data;  
 
public partial class _Default : System.Web.UI.Page   
{  
    RadComboBox ddlOrganization = new Telerik.Web.UI.RadComboBox();  
    protected void Page_Load(object sender, EventArgs e)  
    {  
 
    }  
    protected void Grid_CustomerInSite_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)  
    {   
        DataSet ds=new DataSet();  
        ds.Tables.Add(dtProject());  
        ds.Tables.Add(dtOrganization());  
        this.Grid_CustomerInSite.DataSource = ds;  
    }  
    protected void Grid_CustomerInSite_ItemCreated(object sender, GridItemEventArgs e)  
    {  
        if ((e.Item is GridEditFormItem || e.Item is GridEditFormInsertItem) && e.Item.IsInEditMode)  
        {  
            ddlOrganization = (e.Item as GridEditableItem)["iOrganizationId"].Controls[0] as RadComboBox;  
            if (ddlOrganization != null)  
            {  
                ddlOrganization.AutoPostBack = true;  
                ddlOrganization.SelectedIndexChanged += new RadComboBoxSelectedIndexChangedEventHandler(ddlOrganization_SelectedIndexChanged);  
 
            }  
        }  
    }  
 
 
    protected void ddlOrganization_SelectedIndexChanged(object sender, System.EventArgs e)  
    {  
        int Organization;  
        int.TryParse(ddlOrganization.SelectedValue, out Organization);  
        GridEditableItem editableItem = (sender as Telerik.Web.UI.RadComboBox).NamingContainer as GridEditableItem;  
        RadComboBox ddl = editableItem["iProjectId"].Controls[0] as RadComboBox;  
        DataView dv = new DataView(dtProject(), "iOrganizationId=" + Organization, "", DataViewRowState.CurrentRows);  
        ddl.DataSource = dv;  
        ddl.DataBind();  
 
    }  
 
    public DataTable dtOrganization()  
    {  
        DataTable dt1 = new DataTable();  
        dt1.Columns.Add("iOrganizationId", typeof(Int32));  
        dt1.Columns.Add("nvOrganizationName", typeof(string));  
        DataRow dr1 = dt1.NewRow();  
        dr1["iOrganizationId"] = 1;  
        dr1["nvOrganizationName"] = "לב לאחים";  
        dt1.Rows.Add(dr1);  
        DataRow dr2 = dt1.NewRow();  
        dr2["iOrganizationId"] = 2;  
        dr2["nvOrganizationName"] = "דור ההמשך";  
        dt1.Rows.Add(dr2);  
        return dt1;  
    }  
    public DataTable dtProject()  
    {  
        DataTable dt2 = new DataTable();  
        dt2.Columns.Add("iProjectId", typeof(Int32));  
        dt2.Columns.Add("nvProjectName", typeof(string));  
        dt2.Columns.Add("iOrganizationId", typeof(Int32));  
        dt2.Columns.Add("nvOrganizationName", typeof(string));  
        DataRow dr3 = dt2.NewRow();  
        dr3["iProjectId"] = 1;  
        dr3["nvProjectName"] = "מדרשות";  
        dr3["iOrganizationId"] = 1;  
        dr3["nvOrganizationName"] = "לב לאחים";  
        dt2.Rows.Add(dr3);  
        DataRow dr4 = dt2.NewRow();  
        dr4["iProjectId"] = 2;  
        dr4["nvProjectName"] = "כוללים";  
        dr4["iOrganizationId"] = 1;  
        dr4["nvOrganizationName"] = "לב לאחים";  
        dt2.Rows.Add(dr4);  
        DataRow dr5 = dt2.NewRow();  
        dr5["iProjectId"] = 3;  
        dr5["nvProjectName"] = "סמינרים";  
        dr5["iOrganizationId"] = 2;  
        dr5["nvOrganizationName"] = "דור ההמשך";  
        dt2.Rows.Add(dr5);  
        DataRow dr6 = dt2.NewRow();  
        dr6["iProjectId"] = 4;  
        dr6["nvProjectName"] = "ישיבות";  
        dr6["iOrganizationId"] = 2;  
        dr6["nvOrganizationName"] = "דור ההמשך";  
        dt2.Rows.Add(dr6);  
        return dt2;  
    }  
    protected void Grid_CustomerInSite_UpdateCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)  
    {  
    }  
 
    protected void Grid_CustomerInSite_InsertCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)  
    {  
    }  
}  
 

Thank you for your help.
0
Veli
Telerik team
answered on 22 Jun 2010, 12:59 PM
Hi lea,

Thanks for the sample code. I modified it to work with the GridDropDownListColumnEditor instance that is initialized in the edit form instead of directly binding the combo. Attached is the modified test page. Seems to work OK now. Check it out.

Best wishes,
Veli
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
Chaya Carmi
Top achievements
Rank 1
Answers by
Veli
Telerik team
Chaya Carmi
Top achievements
Rank 1
lea ginsberger
Top achievements
Rank 1
Share this question
or