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

Combobox in Edit Tepmlate Error: Event Listener is null or not an object

3 Answers 93 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mahesh
Top achievements
Rank 1
Mahesh asked on 18 Feb 2009, 12:54 PM
Hello,
I am trying to get a combobox in Edit form as a template.
Firstly I have a RadGrid in that there is a combobox.I binded that successfully.
Upto here there is no problem.But now I have a Edit template form which opens on click of update button.
Here I have two textbox and a combo as a template.I want to show all values in Edit combo that are present in grids combo.I can fetch that again from a database.But the selected value should be same as Grid's combo's selected value.
How to do that.I tried by findcontrol method.I am getting correct combo from edit form.
But when I bind that to database I am not getting.


my Error:

Add Event Listener is null or not an object



My ASPX:

Combobox1 for grid
Combobox2 for Edit Template.

<EditFormSettings EditFormType="Template">

<EditColumn UniqueName="EditCommandColumn1"></EditColumn>

 

                    <FormStyle BackColor="#ECFED8" />

                    <FormTemplate>

                        <table id="Table1" cellspacing="1" cellpadding="1" width="250" border="0">

                            <tr>

                                <td>

                                </td>

                                <td>

                                </td>

                            </tr>

                            <tr>

                                <td>

                                    Employee_Name:</td>

                                <td>

                                    <asp:TextBox ID="TextBox10" Text='<%# Bind( "Employee_Name") %>' runat="server">

                                    </asp:TextBox></td>

                            </tr>

                            <tr>

                                <td>

                                    Designation:</td>

                                <td>

                                    <asp:TextBox ID="TextBox11" Text='<%# Bind( "Employee_Designation") %>' runat="server">

                                    </asp:TextBox></td>

                            </tr>

                            <tr><telerik:RadComboBox  ID="RadComboBox3" runat="server"></telerik:RadComboBox>

                                   </tr></td></td>

                            </tr>

                        </table>

                        <table style="width: 100%">

                            <tr>

                                <td align="right" colspan="2">

                                    <asp:Button ID="Button1" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>'

                                        runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'>

                                    </asp:Button>&nbsp;

                                    <asp:Button ID="Button2" Text="Cancel" runat="server" CausesValidation="False" CommandName="Cancel">

                                    </asp:Button>

                                </td>

                            </tr>

                        </table>

                    </FormTemplate>

                </EditFormSettings>

CS


 

 protected void RadGrid2_ItemDataBound(object sender, GridItemEventArgs e)

 {

 

     if (e.Item is Telerik.Web.UI.GridDataItem)

     {

 

         Telerik.Web.UI.RadComboBox cmb = (Telerik.Web.UI.RadComboBox)e.Item.FindControl("RadComboBox1");

         SqlConnection = new SqlConnection("Server=ma;DataBase=Test;User=sa;Password=");

         SqlDataAdapter da = new SqlDataAdapter("Select Employee_Id from Employee_Master", SqlConnection);

         DataTable dt1 = new DataTable();

         da.Fill(dt1);

         //string[] options = { "OptionA", "OptionB", "OptionC" };

         cmb.DataSource = dt1;

         cmb.DataMember = "Employee_Id";

         cmb.DataTextField = "Employee_Id";

         //cmb.SelectedIndex = i;

         cmb.DataBind();

         cmb.SelectedItem.Text = dt1.Rows[i]["Employee_Id"].ToString();

         i++;

 

     }

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

     {                        

         //GridEditFormItem editFormItem = e.Item as GridEditFormItem;

         //GridDataItem parentItem = editFormItem.ParentItem;

         //Telerik.Web.UI.RadComboBox box = editFormItem.FindControl("RadComboBox3") as Telerik.Web.UI.RadComboBox;

         SqlConnection = new SqlConnection("Server=ma;DataBase=Test;User=sa;Password=");

         SqlDataAdapter da1 = new SqlDataAdapter("Select Employee_Id from Employee_Master", SqlConnection);

         DataTable dt1 = new DataTable();

         da1.Fill(dt1);

         //box.DataTextField = parentItem["Employee_Name"].Text;

         //box.DataSource = dt1;

         //box.DataMember = "Employee_Id";

         //box.DataTextField = "Employee_Id";

         GridEditFormItem formItem = (GridEditFormItem)e.Item;

         RadComboBox dropdown = (RadComboBox)formItem.FindControl("RadComboBox3");

         dropdown.DataSource= dt1;

         dropdown.DataTextField = "Employee_Id";

         dropdown.DataValueField = "Employee_Id";

         dropdown.SelectedValue = DataBinder.Eval(formItem.DataItem, "Employee_Id").ToString();

 

 

     }

 


Thanks in advance,
-Mahesh

3 Answers, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 23 Feb 2009, 08:33 AM
Hello Mahesh,

Does the code still throw the exception if you comment the line where you set the selected item for the combo? Additionally, is the exception raised in the first, or the second if block?

All the best,
Yavor
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Mahesh
Top achievements
Rank 1
answered on 26 Feb 2009, 09:12 AM
Hi thanks for Reply.
I think My Error Comes in second if block.Error comes with a alert block saying "The contents in webpage might be prevent to show properly....." with char:1 and line number and add Event Listener is null or not an object.
I can see contents but scattered here and there. 
Shall I send ScreenShot?
Thanks in advance.
-Mahesh
0
Yavor
Telerik team
answered on 03 Mar 2009, 09:23 AM
Hi Mahesh,

Basically, based on this information, it is hard to determine what is causing this issue. To further address it, you can open a formal support ticket, and send us the problematic code, in the form of a small working project, for additional testing and review.

Kind regards,
Yavor
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Mahesh
Top achievements
Rank 1
Answers by
Yavor
Telerik team
Mahesh
Top achievements
Rank 1
Share this question
or