locked
Telerik Grid Problem RRS feed

  • Question

  • User-258838285 posted

    Hi Team,

    I am Using Telerik RAD Grid.

    I am using This Code To Bind GridView AS per Combobox Selected Item.

    protected void RadComboBox1_SelectedIndexChange(object o, RadComboBoxSelectedIndexChangedEventArgs e)
        {
    
            if (RadComboBox1.SelectedItem != null)
            {
                string Text = RadComboBox1.SelectedItem.Text.ToString();
                string qrySelect = "Select * from Category Where Categoryname = '" + Text + "'";
                ds = obj.SelectQuery(qrySelect);
                RadGrid2.DataSource = ds;
                RadGrid2.DataBind();
                mvMain.SetActiveView(vwSearchGrid);
            }
        }

    And Also using Rad Context Menu. But When Popelates Rad Context Menu and Press Edit it Will Give an Error." There Is No row at Position 0"
    protected void RadMenu1_ItemClick(object sender, RadMenuEventArgs e)
        {
            foreach (GridDataItem item in RadGrid1.MasterTableView.Items)
            {
                if (item.Selected)
                {
    
                    strtxt = item["ID"].Text.ToString();
                    Session["EditID"] = strtxt;
                }
            }
    
            switch (e.Item.Text)
            {
                case "Edit":
                    string qrySelect = "Select * from Category Where ID = '" + strtxt + "'";
                    ds = obj.SelectQuery(qrySelect);
                    TextBox1.Text = ds.Tables[0].Rows[0][1].ToString();
                    Session["mode"] = "Edit";
                    mvMain.SetActiveView(vwSubmit);
                    RadGrid1.Rebind();
                    break;
                case "Delete":
                    string qryDelete = "Delete From Category Where ID = '" + Convert.ToInt16(strtxt) + "'";
                    int i = obj.FireQuery(qryDelete);
                    Response.Write("<script>alert('Are You Sure want to Delete.?')</script>");
                    RadGrid1.Rebind();
                    break;
            }
            disableControls();
        }

    How to Solve It...?

    PLease Help

    Friday, April 22, 2011 12:52 AM

Answers

  • User-1034726716 posted

    No It Will not Return Any Rows There.....!!!

    Then that means your sql query doesn't return an data at all..  and that's why it throws an error because you referenced a row in the DataTable that dont have any data at all.

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, April 28, 2011 11:37 PM

All replies

  • User-1034726716 posted

    Have you checked if your query returns any rows? Before assigning value to your checkbox try to check for the row count like:

    if(ds.Tables[0].Rows[0].Count > 0){

    //Populate your TextBox

    }

    Monday, April 25, 2011 7:42 AM
  • User-258838285 posted

    No It Will not Return Any Rows There.....!!!

    Thursday, April 28, 2011 1:06 AM
  • User-1034726716 posted

    No It Will not Return Any Rows There.....!!!

    Then that means your sql query doesn't return an data at all..  and that's why it throws an error because you referenced a row in the DataTable that dont have any data at all.

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, April 28, 2011 11:37 PM
  • User-258838285 posted

    THnx Got the Problem

     

    Friday, May 6, 2011 8:04 AM