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'
sadhana sawantPosted Feb 9, 2015, 6:41 AM
Shweta LodhaPosted Feb 6, 2015, 5:01 AM
Please replace custID with the column of your table. That should resolve your issue.
sadhana sawantPosted Feb 6, 2015, 4:46 AM
Santhakumar MunuswamyPosted Feb 6, 2015, 4:27 AM
Could you please try below code
Convert.ToInt64(((DataRowView)cmdCustomer.SelectedValue)["custID"]);