从上面的标题来看,我的代码在第一次page_load时没有问题,它显示正确,但是在我单击按钮更改语言后,它就消失了(只显示标题)。我花了大约一周的时间来找出答案,但仍然找不到发生了什么。如果可见数据大于 1,则其工作正常。
编辑:忘了把我的页面加载方法
protected void Page_Load(object sender, EventArgs e)
{
NoResult.Visible = false;
Get_Data();
}
protected void Get_Data()
{
DBCAD.Service1 myCADDB = new DBCAD.Service1();
myCADDB.UseDefaultCredentials = true;
string result = "";
//set web service proxy
if (!GlobalVariable_CCCNS.filterOrNot)
{
//invoke web service method
result = myCADDB.CallCardStatus_Filter_CCCNSEMBILAN_ALL();
}
else
{
GlobalVariable_CCCNS.FilterDC = DropDownList1.SelectedValue;
//invoke web service method
if (GlobalVariable_CCCNS.FilterDC == "CCC NS ALL")
{
result = myCADDB.CallCardStatus_Filter_CCCNSEMBILAN_ALL();
}
else
{
result = myCADDB.CallCardStatus_Filter(GlobalVariable_CCCNS.FilterDC);
}
}
//read the response data and put in xml document
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(result);
string mypath = Server.MapPath(@"Data.xml");
//XmlTextReader reader = new XmlTextReader ("DBCAD.xml");
xmlDoc.Save(mypath);
//set the data set
DataSet ds = new DataSet();
ds.ReadXml(mypath);
//Open hidden column
CallCardStatus.Columns[0].Visible = true;
if (ds.Tables.Count > 0)
{
//list out the result to Data Grid
CallCardStatus.DataSource = ds;
CallCardStatus.DataBind();
}
else
{
NoResult.Visible = true;
}
//Clear Unwanted Column
CallCardStatus.Columns[0].Visible = false;
}
这是我的 RowDataBound
string lastRow = "";
protected void CallCardStatus_RowDataBound(object sender, GridViewRowEventArgs e)
{
//Many item with same id but different status, I just want to visible and get the first row for each id.
if (e.Row.RowType == DataControlRowType.DataRow)
{
var thisRow = e.Row;
if (thisRow.Cells[0].Text == lastRow)
{
e.Row.Visible = false;
}
lastRow = thisRow.Cells[0].Text;
}
}
这是我的马来语和英语单选按钮
protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)
{
GlobalVariable_CCCNS.cultureName = RadioButtonList1.SelectedValue.ToString();
Page.Culture = GlobalVariable_CCCNS.cultureName;
Page.UICulture = GlobalVariable_CCCNS.cultureName;
if (GlobalVariable_CCCNS.cultureName == "ms-MY")
{
Label2.Visible = false;
Label2.Text = "Kawalan Status Kad Panggilan";
Label2.Visible = true;
}
else
{
Label2.Visible = false;
Label2.Text = "CallCard Status Monitoring";
Label2.Visible = true;
}
Page_Render();
}
protected void Page_Render()
{
Page.Culture = GlobalVariable_CCCNS.cultureName;
Page.UICulture = GlobalVariable_CCCNS.cultureName;
ALL.Text = GetLocalResourceObject("ALLResource1.Text").ToString();
Label1.Text = GetLocalResourceObject("Label1Resource1.Text").ToString();
NoResult.Text = GetLocalResourceObject("NoResultResource1.Text").ToString();
DBCAD.Service1 myCADDB = new DBCAD.Service1();
myCADDB.UseDefaultCredentials = true;
string result = "";
//set web service proxy
if (!GlobalVariable_CCCNS.filterOrNot)
{
//invoke web service method
result = myCADDB.CallCardStatus_Filter_CCCNSEMBILAN_ALL();
}
else
{
GlobalVariable_CCCNS.FilterDC = DropDownList1.SelectedValue;
//invoke web service method
if (GlobalVariable_CCCNS.FilterDC == "CCC NS ALL"){
result = myCADDB.CallCardStatus_Filter_CCCNSEMBILAN_ALL();
}else{
//invoke web service method
result = myCADDB.CallCardStatus_Filter(GlobalVariable_CCCNS.FilterDC);
}
}
//read the response data and put in xml document
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(result);
string mypath = Server.MapPath(@"Data.xml");
//XmlTextReader reader = new XmlTextReader ("DBCAD.xml");
xmlDoc.Save(mypath);
//set the data set
DataSet ds = new DataSet();
ds.ReadXml(mypath);
// CallCardStatus.DataSource = ds;
//CallCardStatus.DataBind();
//Open hidden column
CallCardStatus.Columns[0].Visible = true;
if (ds.Tables.Count > 0)
{
//list out the result to Data Grid
CallCardStatus.DataSource = ds;
CallCardStatus.Columns[2].HeaderText = GetLocalResourceObject("ButtonFieldResource1.Text").ToString();
CallCardStatus.Columns[3].HeaderText = GetLocalResourceObject("BoundFieldResource3.HeaderText").ToString();
CallCardStatus.Columns[4].HeaderText = GetLocalResourceObject("BoundFieldResource4.HeaderText").ToString();
CallCardStatus.Columns[5].HeaderText = GetLocalResourceObject("BoundFieldResource5.HeaderText").ToString();
CallCardStatus.Columns[6].HeaderText = GetLocalResourceObject("BoundFieldResource6.HeaderText").ToString();
CallCardStatus.Columns[7].HeaderText = GetLocalResourceObject("BoundFieldResource7.HeaderText").ToString();
CallCardStatus.Columns[8].HeaderText = GetLocalResourceObject("BoundFieldResource8.HeaderText").ToString();
CallCardStatus.Columns[9].HeaderText = GetLocalResourceObject("BoundFieldResource9.HeaderText").ToString();
CallCardStatus.DataBind();
}
else
{
NoResult.Visible = true;
}
//Clear Unwanted Column
CallCardStatus.Columns[0].Visible = false;
}
任何人都可以帮忙吗?谢谢..Siti..:)