Click here to Skip to main content
15,887,027 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
i need to add a row in radGridView(which is bind with data table) when i click any item on list control. i have my code that is working just fine .the issue is that i dont know which specific event of radlistControl to use for this thing to work.

i have tried selectedindexchanged event but its not working . i have tried listcontrol_click event and it gives me previous selected value on click.

here is my code.. kindly tell me where is the problem(i am working on winforms)

What I have tried:

private void othersList_SelectedIndexChanged(object sender, telerik.WinControls.UI.Data.PositionChangedEventArgs e)

    {
        try
        {
            OracleConnection conn = new OracleConnection(userobj.oradb);

            conn.Open();
            OracleCommand cmd = new OracleCommand("select RATE from HRM_CANTEEN_ITEMS where ITEM_NAME='" + othersList.SelectedItem.ToString() + "' AND ITEM_CODE =" + othersList.SelectedValue + "  AND CANTEEN_SEQ_NO =" + canCode + "", conn);
            OracleDataReader drr = cmd.ExecuteReader();

            while (drr.Read())
            {
                item_rate = double.Parse(drr["RATE"].ToString());
            }
            conn.Close();


            DataRow dr = gvdt.NewRow();
            //addrows
            dr["ITEM_CODE"] = othersList.SelectedValue.ToString();
            dr["ITEM_NAME"] = othersList.SelectedItem.ToString();
            dr["RATE"] = item_rate;
            dr["QUANTITY"] = item_quantity;
            dr["SUB_AMOUNT"] = item_rate;

            gvdt.Rows.Add(dr);

            billGv.DataSource = gvdt;
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.ToString());
        }

    }
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900