how to remove this error "system..data.datrowview "in comboox.?

Posted by Rock_Monu under ASP.NET on 8/7/2012 | Points: 10 | Views : 1406 | Status : [Member] | Replies : 8
how to remove error "system..data.datrowview" in comboox in windows form application..????




Responses

Posted by: Gopesh9 on: 8/7/2012 [Member] Starter | Points: 25

Up
0
Down
Can you give the information about the total error which you are getting??

G. S.
.Net Developer

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

Posted by: Rock_Monu on: 8/7/2012 [Member] Starter | Points: 25

Up
0
Down
when page is load then in combobox have item name syastem.data.datarow view plce on items..?????

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

Posted by: Gopesh9 on: 8/7/2012 [Member] Starter | Points: 25

Up
0
Down
You can clear all the items from the combobox when the page loads for the 1st time using IsPostback and when the page is added for the postback then retain the previous value of the ComboBox.

G. S.
.Net Developer

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

Posted by: Rock_Monu on: 8/8/2012 [Member] Starter | Points: 25

Up
0
Down
but in windows form haven't "is post back".and when form load i use "cmb_country.item.clear".but it is not working.

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

Posted by: Gopesh9 on: 8/8/2012 [Member] Starter | Points: 25

Up
0
Down
Ohk you are using Windows form, please give the total code which you are writing in your application. So that i can go through the exact error which you are facing.

G. S.
.Net Developer

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

Posted by: Rock_Monu on: 8/8/2012 [Member] Starter | Points: 25

Up
0
Down
private void Frm_District_Master_Load(object sender, EventArgs e)
{
try
{
cmb_country.Items.Clear();
FillCountry();
}
catch

{
}
this is code..

public void FillCountry()
{
DataTable dt = new DataTable();
cmb_country.Items.Clear();
dt = cn.getvalues("select countryid,countryname from tbl_country");

cmb_country.DataSource = dt;
cmb_country.ValueMember = "countryid";
cmb_country.DisplayMember = "countryname";
cmb_country.SelectedIndex = -1;
FillState();
}
public void FillState()
{
cmb_country.DisplayMember = "";
DataTable dt = new DataTable();

dt = cn.getvalues("select stateid,statename from tbl_state where countryid ='" + cmb_country.SelectedValue +"' ");
cmb_statename.DataSource = dt;

cmb_statename.ValueMember = "stateid";
cmb_statename.DisplayMember = "statename";

cmb_statename.SelectedIndex = -1;

}

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

Posted by: Rock_Monu on: 8/8/2012 [Member] Starter | Points: 25

Up
0
Down
@Gopesh Sharma
wt happend gopesh plz give me reply..:)

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

Posted by: Gopesh9 on: 8/8/2012 [Member] Starter | Points: 25

Up
0
Down
Try this...

comboBox1.Items.Clear();

comboBox1.Text = "Select State";
try
{
conn.Open();
str1 = "select distinct StateID from State";
cmd = new SqlCommand(str1, conn);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
comboBox1.Items.Add(dr[0]);
}

dr.Close();


G. S.
.Net Developer

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

Login to post response