Click here to Skip to main content
15,877,376 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
i need one help in my code. i am using a window based application . in my code
i have one combobox(courtnamelist) which is a category. ane sub categories where i have kept five more comboboxs(heighcourtlist,labourcourtlist,distictcourt..ect)
i want, when i select courtnamelist item's so its corresponding combobox list should be visible and when i choose corresponding list item and click the add button so item should be insert into the database columns..
i have created a void method and i have wrote all codes into it .
i have tried but i am not able to get the results . please check my codes and show me the right path of my codes

public void data2()
               int index1 = courtnamelist.SelectedIndex;
               if (0 == index1)
                   supremecourtlist.Visible = true;

                con = new SqlConnection("Data Source=.;Initial Catalog=DSIIDC2;Integrated Security=True");
                string str = "insert into addcaasedetails(caseno,casetype,courtname,feetocounsil,record,nextdateofhearing,status,supremecourtbranch) values(@caseno,@casetype,@courtname,@nameofcourt,@feetocounsil,@record,@nextdateofhearing,@status,@supremecourtbranch)";
                cmd = new SqlCommand(str, con);

                cmd.Parameters.AddWithValue("@caseno", Convert.ToInt32(txtcaseno.Text));
                cmd.Parameters.AddWithValue("@casetype", casetypelist.SelectedItem);
                cmd.Parameters.AddWithValue("@courtname", courtnamelist.SelectedItem);
                cmd.Parameters.AddWithValue("@nameofcounsil", txtnameofthecounsel.Text);
                cmd.Parameters.AddWithValue("@feetocounsil", Convert.ToDecimal(feespaybletothecounsel.Text));
                cmd.Parameters.AddWithValue("@nextdateofhearing", nextstatusofcounseldateTimePicker1.Value);
                cmd.Parameters.AddWithValue("@status", txtstatus.Text);
                cmd.Parameters.AddWithValue("@record", txtrecords.Text);
                cmd.Parameters.AddWithValue("@supremecourtbranch", supremecourtlist.SelectedItem);
               // cmd.Parameters.AddWithValue("@heighcourtbranch", heighcourtlist.SelectedItem);

                SqlDataAdapter da = new SqlDataAdapter(cmd);
                DataSet ds = new DataSet();


               else if(1==index1)
                   heighcourtlist.Visible = true;
               else if (2 == index1)
                   districtcourtlist.Visible = true;
               else if (3 == index1)
                   nationlgreentribunallict.Visible = true;

Updated 12-Jun-15 0:51am

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