Tuesday, 3 September 2013

databind in gridview from dropdownlists

databind in gridview from dropdownlists

I have two dropdownlists on my webform. dlName and dlStage. I have a
gridview that needs to be based on the values selected from these two drop
downs. Currently, I am not filtering the gridview and I am using the
following code:
private void BindData()
{
string query = "select
[AnnotationNumber],[AnnotationBy],[AnnotationType],[BusinessUnit]
as
Unit,[ErrorType],[ActualAgencyError],AnnotationComments,[sgkComments],[ActualAgencyError],Cust,Name,AnnotationDate
from vw_GridviewSource ";
SqlCommand cmd = new SqlCommand(query);
gvSummary.DataSource = GetData(cmd);
gvSummary.DataBind();
}
What I would like to do is have the gridview always check the drop downs
and bind data based on the values in the drop down lists.
At the end of the select statement two values Name and AnnotationDate are
the variables that would need to be matched. I included them in the query
because I was trying to use a datakey to bind the data but that failed.
I am pretty new to this so I can use all the help possible.

No comments:

Post a Comment