【发布时间】:2013-03-28 18:43:07
【问题描述】:
我在我的页面上放置了一个 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();
}
}
}
点击按钮后没有出现网格视图,请帮助我。
【问题讨论】:
-
可能是回发的事情。您是在动态创建网格吗?
-
我在页面上放置了一个 gridview 并将其链接到一个数据库表,并且在代码中我已经这样做了 --> GridViewFemale.DataSource = SearchResultsGirls; , GridViewFemale.DataBind();
-
LinqDataSourceFemale,GridViewFemale 哦,伙计。 10rem.net/articles/…
标签: c# asp.net linq search gridview