asp.net c# function isPostBack

felixpelican

New Member
I am implementing a gridview on a asp page. On the page load, I will only show 1 record on the gridview. But when i click on the button_5 and button_10, it should show 5 records and 10 records on the gridview respectively. However, this is not happening. Are there any ways I can do to my codes to resolve this? Thanks in advance!I have the following piece of code:\[code\]protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { showUploadSummaryAE(); } } protected void showUploadSummaryAE() { aeGridView.Visible = true; String connectionString = DAO.GetConnectionString(); SqlConnection conn = new SqlConnection(connectionString); String sqlQuery = "select top 1 id,DateTime_Added,Filename,NoOfExcelRows,NoOfNewRecordsAdded,NoOfError,Department from uploadSummaryDB where department = 'A&E' order by datetime_added desc"; conn.Open(); SqlDataAdapter dataAdapter = new SqlDataAdapter(sqlQuery, conn); DataSet dataset = new DataSet(); dataAdapter.Fill(dataset, "uploadSummaryDB"); aeGridView.DataSource = dataset.Tables[0]; aeGridView.DataBind(); aeGridView.HeaderRow.Cells[0].Text = "Download Error File"; aeGridView.HeaderRow.Cells[1].Text = "File ID"; aeGridView.HeaderRow.Cells[2].Text = "Date & Time Added"; aeGridView.HeaderRow.Cells[3].Text = "Filename"; aeGridView.HeaderRow.Cells[4].Text = "Number of rows found"; aeGridView.HeaderRow.Cells[5].Text = "Number of rows inserted"; aeGridView.HeaderRow.Cells[6].Text = "Number of error rows found"; conn.Close(); }protected void button5_Click(object sender, EventArgs e) { aeGridView.Visible = true; String connectionString = DAO.GetConnectionString(); SqlConnection conn = new SqlConnection(connectionString); String sqlQuery = "select top 5 id,DateTime_Added,Filename,NoOfExcelRows,NoOfNewRecordsAdded,NoOfError,Department from uploadSummaryDB where department = 'A&E' order by datetime_added desc"; conn.Open(); SqlDataAdapter dataAdapter = new SqlDataAdapter(sqlQuery, conn); DataSet dataset = new DataSet(); dataAdapter.Fill(dataset, "uploadSummaryDB"); aeGridView.DataSource = dataset.Tables[0]; aeGridView.DataBind(); aeGridView.HeaderRow.Cells[0].Text = "Download Error File"; aeGridView.HeaderRow.Cells[1].Text = "File ID"; aeGridView.HeaderRow.Cells[2].Text = "Date & Time Added"; aeGridView.HeaderRow.Cells[3].Text = "Filename"; aeGridView.HeaderRow.Cells[4].Text = "Number of rows found"; aeGridView.HeaderRow.Cells[5].Text = "Number of rows inserted"; aeGridView.HeaderRow.Cells[6].Text = "Number of error rows found"; conn.Close(); } protected void button10_Click(object sender, EventArgs e) { aeGridView.Visible = true; String connectionString = DAO.GetConnectionString(); SqlConnection conn = new SqlConnection(connectionString); String sqlQuery = "select top 10 id,DateTime_Added,Filename,NoOfExcelRows,NoOfNewRecordsAdded,NoOfError,Department from uploadSummaryDB where department = 'A&E' order by datetime_added desc"; conn.Open(); SqlDataAdapter dataAdapter = new SqlDataAdapter(sqlQuery, conn); DataSet dataset = new DataSet(); dataAdapter.Fill(dataset, "uploadSummaryDB"); aeGridView.DataSource = dataset.Tables[0]; aeGridView.DataBind(); aeGridView.HeaderRow.Cells[0].Text = "Download Error File"; aeGridView.HeaderRow.Cells[1].Text = "File ID"; aeGridView.HeaderRow.Cells[2].Text = "Date & Time Added"; aeGridView.HeaderRow.Cells[3].Text = "Filename"; aeGridView.HeaderRow.Cells[4].Text = "Number of rows found"; aeGridView.HeaderRow.Cells[5].Text = "Number of rows inserted"; aeGridView.HeaderRow.Cells[6].Text = "Number of error rows found"; conn.Close(); }\[/code\]
 
Back
Top