delete item from combobox

Posted by Chilverupavan under C# on 5/15/2010 | Views : 8132 | Status : [Member] | Replies : 6
hi friend,,

iam deleting an item in combobox which an items are retreving from database.
but my probelm is when i delete a particular item in combbox the item is deleting from combobox,
but the item is still displaying in combobox,but when i refresh the form then the deleted item is not displaying.
so my query is the selected item should delete from combbox and should be display in combobox..............
please help me




Responses

Posted by: Er.deepakdalal on: 5/16/2010 [Member] Starter

Up
0
Down
Hi Chilverupavan

checkout the below link


http://www.daniweb.com/forums/thread166169.html

Chilverupavan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Diya0076 on: 5/16/2010 [Member] Starter

Up
0
Down
have you again bind the combobox after deletion?

Chilverupavan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Chilverupavan on: 5/16/2010 [Member] Starter

Up
0
Down
yes i had again bind the combobox after deletion...

Chilverupavan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Diya0076 on: 5/16/2010 [Member] Starter

Up
0
Down
ok..

Is your page is on updatePanel ???

and is the combobox is on same page or is on userControl ?

Chilverupavan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Syedshakeer on: 5/16/2010 [Member] Starter

Up
0
Down
Hi,
In delete Button.write the code to delete the selected item from a ComboBox.

SqlCommand cmd=new SqlCommand("delete from tablename where id="+ComboBox1.SeletedValue+"",conn);

cmd.ExecuteNonQuery();

//after bind the Combobox as follows
SqlDataAdapter da=new SqlDataAdapter("select orderid,ordername from tablename",conn);
DataSet da=new DataSet();
da.Fill(ds,"tablename");
ComboBox1.DataSource = ds;
ComboBox1.DisplayMember = ds.Tables["tablename"].Columns["orderid"];
ComboBox1.ValueMember = ds.Tables["tablename"].Columns["ordername "];


Syed Shakeer Hussain

Chilverupavan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Neeks on: 7/16/2010 [Member] Bronze

Up
0
Down
Are you binding the ComboBox at the PageLoad?

So, please check the IsPostBack property for the page.

Can you please debug the code and check whether the binding of the Comobox is done again or not

Chilverupavan, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response