here is my code:
private void cmbCustomer_SelectedIndexChanged(object sender, EventArgs e)
{
//id = Convert.ToInt64(cmbCustomer.SelectedValue);
DataSet ds = new DataSet();
SqlCommand cmd = new SqlCommand("select * from RM_Customer where custID ='" +Convert.ToInt64(cmbCustomer.SelectedValue) + "'", cn);
cn.Close();
cn.Open();
SqlDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
txtaddress.Text = dr["custAddress"].ToString();
}
dr.Close();
cn.Close();
}
i got error like this:
Unable to cast object of type 'System.Data.DataRowView' to type 'System.IConvertible'

Santhakumar MunuswamyRank #128 · 17.3K reputationPosted Feb 5, 2015, 11:27 PM EST
Could you please try below code
Convert.ToInt64(((DataRowView)cmdCustomer.SelectedValue)["custID"]);
sadhana sawant5 reputationPosted Feb 5, 2015, 11:46 PM EST
Shweta LodhaRank #31 · 39.8K reputationPosted Feb 6, 2015, 12:01 AM EST
Please replace custID with the column of your table. That should resolve your issue.
sadhana sawant5 reputationPosted Feb 9, 2015, 1:41 AM EST