muneeba mujeeb Ответов: 0

Добавить строку в datatable на listcontrol нажмите кнопку


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());
        }

    }

0 Ответов