Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
215
WebCombo FindByText
posted

I have a webcombo on my Asp.net page which is bound to a data table.

 this.WebCombo1.DataSource = DataSet1.tblBankAccounts;this.WebCombo1.DataMember = "tblBankAccounts";this.WebCombo1.DataTextField = "AccountNumber";this.WebCombo1.DataValueField = "pk_BankAccount";this.WebCombo1.DataBind();  

Then when I try to set the selected index of the webcombo I get an “Object reference not set to an instance of an object.” error.

  this.WebCombo1.SelectedIndex = this.WebCombo1.FindByText("1235684").Row.Index; 

I double checked that the value is present in the data table.

 

The thing is that it does not throw the error when the AutoGenerateColumns attribute is set to true. As soon as the AutoGenerateColumns is set to false I receive this error.

 

Thanks