protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { DataClassesDataContext db = new DataClassesDataContext(); db.Connection.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["Cn"].ConnectionString; if (e.CommandName == "view") { int StateId = Convert.ToInt32(e.CommandArgument); HiddenField1.Value = StateId.ToString(); var state = ( from s in db.tblStates where (s.Stateid == Convert.ToInt32(e.CommandArgument)) select new { s.StateName, s.Countryid } ).FirstOrDefault(); if (state != null) { TextBox1.Text = state.StateName; DropDownList1.SelectedValue = state.Countryid; } } }
System.InvalidCastException: Unable to cast object of type 'System.Int32' to type 'System.String'. Source Error: Line 78: int StateId = Convert.ToInt32(e.CommandArgument); Line 79: HiddenField1.Value = StateId.ToString(); Line 80: var state = Line 81: ( Line 82: from s in db.tblStates
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)