在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 –