Object doesn't support this action

5 posts, 0 answers
  1. Selvamanikandan
    Selvamanikandan avatar
    4 posts
    Member since:
    Oct 2012

    Posted 17 Jun 2013 Link to this post

    When i'm trying to bind a record from one grid view to another grid view using item command event i'm facing the following error.

    "Object Doesn't support this action". please help me regarding this.
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 17 Jun 2013 Link to this post

    Hi,

    I tried to bind a record from one RadGrid to another and it worked as expected. Here is the sample code.
    C#:
    protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
    {
     if (e.CommandName == RadGrid.SelectCommandName && e.Item is GridDataItem)
     {
        GridDataItem item = (GridDataItem)e.Item;
        DataTable dt1 = (DataTable)Session["dt"];//first grid datasource
        DataTable dt = dt1.Clone();
        DataRow dr = dt.NewRow();
        dr["CustomerID"] = item["CustomerID"].Text;
        dr["ContactName"] = item["ContactName"].Text;
        dr["City"] = item["City"].Text;
        dt.Rows.Add(dr);
        radgrid2.DataSource = dt;
        radgrid2.DataBind();
     }
    }

    Thanks,
    Shinu.
  3. Selvamanikandan
    Selvamanikandan avatar
    4 posts
    Member since:
    Oct 2012

    Posted 18 Jun 2013 Link to this post

    Microsoft JScript runtime error: Unable to set value of the property 'control': object is null or undefined. i'm getting the below error while adding items to one radgrid to another radgrid. kindly help me.
  4. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 21 Jun 2013 Link to this post

    Hi,

    Unfortunately I couldn't replicate the issue at my end. Here is the complete Code snippet I tried.

    ASPX:
    <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="false" OnItemCommand="RadGrid1_ItemCommand"
        OnNeedDataSource="RadGrid1_NeedDataSource">
        <MasterTableView>
            <Columns>
                <telerik:GridBoundColumn DataField="OrderID">
                </telerik:GridBoundColumn>
                <telerik:GridButtonColumn CommandName="Select" Text="select">
                </telerik:GridButtonColumn>
            </Columns>
        </MasterTableView>
    </telerik:RadGrid>
    <br />
    <telerik:RadGrid ID="RadGrid2" runat="server" AutoGenerateColumns="false">
        <MasterTableView>
            <Columns>
                <telerik:GridBoundColumn DataField="OrderID">
                </telerik:GridBoundColumn>
            </Columns>
        </MasterTableView>
    </telerik:RadGrid>

    C#:
    public static string connection = WebConfigurationManager.ConnectionStrings["NorthwindConnectionString3"].ConnectionString;
    SqlConnection conn = new SqlConnection(connection);
    public SqlCommand SqlCommand = new SqlCommand();
    protected void RadGrid1_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
    {
        string selectQuery1 = "select top 10 OrderID  from Orders";
        SqlDataAdapter adapter1 = new SqlDataAdapter(selectQuery1, conn);
        conn.Open();
        DataTable dt = new DataTable();
        adapter1.Fill(dt);
        conn.Close();
        Session["dt"] = dt;
        RadGrid1.DataSource = dt;
    }
    protected void RadGrid1_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
    {
        if (e.CommandName == RadGrid.SelectCommandName && e.Item is GridDataItem)
        {
            GridDataItem item = (GridDataItem)e.Item;
            DataTable dt1 = (DataTable)Session["dt"];
            DataTable dt = dt1.Clone();
            DataRow dr = dt.NewRow();
            dr["OrderID"] = item["OrderID"].Text;
            dt.Rows.Add(dr);
            RadGrid2.DataSource = dt;
            RadGrid2.DataBind();
        }
    }

    Thanks,
    Princy.
  5. Selvamanikandan
    Selvamanikandan avatar
    4 posts
    Member since:
    Oct 2012

    Posted 21 Jun 2013 Link to this post

    Thanks Princy..finally i found out the error its becuase of i've set one control as visible="false" and tried to get the value from that control so javascript error occured. thanks for ur reply.
Back to Top