protected void grvAuthor_SelectedIndexChanged(object sender, EventArgs e) { Label lblID = (Label)grvAuthor.Rows[grvAuthor.SelectedIndex].FindControl("Label1"); SqlDataReader dr = helperclass.fillAllData("Select * from RACKDETAILS where RACKID='"+lblID.Text+"'"); if (dr.Read()) { txtRackId.Text = dr["RACKID"].ToString(); txtRackName.Text = dr["RACKNAME"].ToString(); txtRackRemarks.Text = dr["REMARKS"].ToString(); } else { ScriptManager.RegisterStartupScript(this.Page, typeof(string), "", "alert('Error in Connection...');", true); } }
public static SqlDataReader fillAllData(string query) { SqlDataReader dr = null; using (SqlConnection con = new SqlConnection(helperclass.constring)) { SqlCommand cmd = new SqlCommand(query, con); if (con.State == ConnectionState.Closed) con.Open(); dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); return dr; } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)