The reason for binding gridview twice is, when the page loads for the first
time, GridView will display all information.
There is a search user control(.ascx) which contains dropdown boxes for
selection and submit button to perform search. Now when submit button is
clicked it will reload the .aspx page passing search parameters. I created
another SQL statement using this search parameter and bind it to grid to
display new information on page load.
I know it have to do something with ViewState. I just wanted to know if
there is any other suitable way to perform search and filter the content of
the GridView without losing the ViewState information. The reason i don't
wanted to lose ViewState Information is I have toggle button inside GridView
which expand and collapse ChildGridVew. Now once ViewState information is
changed, the ChildGridView won't be able to display information as desired.
I'd really appreciate your help.
Thank you.
> protected void Page_Init(object sender, EventArgs e)
> {
> if (!IsPostBack)
> {
> GridView1.DataSource = DataSource;
> GridView1.DataBind();
> }
> }
> protected void Page_Load(object sender, EventArgs e)
> {
> string strSql = "Select * from EMPLOYEE" ;
> strSql = strSql + "Where " + " E_NAME = TEST"; // depends
> on search criteria. For now i have simple SQL statement
>
> DataTable dt =DataSource.GetData();
> DataRow[] dr = dt.Select(strSql);
> GridView1.DataSource = dr;
> GridView1.DataBind();}
>
> protected void GridView1_SelectedIndexChanging(object sender,
> GridViewSelectEventArgs e)
> {
> usercontrol.BuildEmployeRecord(userID, Info);
> }
// This is my user Control(.ascx) file
public partial class usercontrol : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e
public void BuildEmployeRecord(int userID, int Info)
{
}