Skip to content

Instantly share code, notes, and snippets.

Created May 6, 2017 19:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/b8534a37794834d51dff443ede7d7abb to your computer and use it in GitHub Desktop.
Save anonymous/b8534a37794834d51dff443ede7d7abb to your computer and use it in GitHub Desktop.
Gridview - How to Create?
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
BindData();
}
}
public void BindData()
{
String connectstring = ConfigurationManager.ConnectionStrings["myConnectionString1"].ConnectionString;
SqlConnection con=new SqlConnection(connectstring);
DataSet ds = new DataSet();
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "select * from refund_request WHERE orderid=@Value1"; //Query to execute
cmd.Connection = con; // Assign the connection to execute the above query
cmd.Parameters.AddWithValue("@Value1", loginUser); // Provide the input values
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(ds);
con.Open(); // Open the connection to execute the query
cmd.ExecuteNonQuery();
CustomersGridView.DataSource = ds;
CustomersGridView.DataBind();
con.Close();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment