Created
May 6, 2017 19:07
-
-
Save anonymous/b8534a37794834d51dff443ede7d7abb to your computer and use it in GitHub Desktop.
Gridview - How to Create?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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