在GridView中显示的数据我已经把我的页面上的GridView和它连接到LinqDataSourceFemale(数据库的女表),我有如下一个上单击事件,搜索页面
protected void ButtonSearch_Click(object sender, EventArgs e)
{
using(BerouDataContext Data = new BerouDataContext())
{
if (DropDownListGender.SelectedItem.Text == "Male")
{
int age = Convert.ToInt32(DropDownListAge.Text);
string education = DropDownListEducation.Text.ToString();
string maritalstatus = DropDownListMaritalStatus.Text.ToString();
//var religion = DropDownListReligion.Text.ToString();
string caste = DropDownListCaste.Text.ToString();
string city = DropDownListCity.ToString();
var SearchResultBoys = Data.Males.Where(tan =>
(tan.Age == age)
&& (tan.Education == education)
&& (tan.Group == maritalstatus)
&& (tan.Caste == caste));
GridViewMale.DataSourceID = "";
GridViewMale.DataSource = SearchResultBoys;
GridViewMale.DataBind();
}
else if (DropDownListGender.SelectedItem.Text == "Female")
{
int age = Convert.ToInt32(DropDownListAge.Text);
string education = DropDownListEducation.Text.ToString();
string maritalstatus = DropDownListMaritalStatus.Text.ToString();
//var religion = DropDownListReligion.Text.ToString();
string caste = DropDownListCaste.Text.ToString();
string city = DropDownListCity.ToString();
var SearchResultGirls = Data.Females.Where(tan =>
(tan.Age == age)
&& (tan.Education == education)
&& (tan.Group == maritalstatus)
&& (tan.Caste == caste));
GridViewFemale.DataSourceID = "";
GridViewFemale.DataSource = SearchResultGirls;
GridViewFemale.DataBind();
}
}
}
搜索事件类似代码网格视图不会出现在按钮点击后,请帮助我。
可能是回传的事情。你在动态创建网格吗? –
我已经把网格放在一个页面上,并将其链接到一个数据库表,并在代码中,我已经做到了 - > GridViewFemale.DataSource = SearchResultsGirls; ,GridViewFemale.DataBind(); – VINNUSAURUS
LinqDataSourceFemale,GridViewFemale户外的人。 http://10rem.net/articles/net-naming-conventions-and-programming-standards---best-practices –