这里发生了一件奇怪的事。我已经按照我想要的方式运行了我的页面的功能,但是有一些布局问题并不是我真正想要的。因此,在尝试解决这些问题时,我发现构建新的母版页比使用默认的Site.master页面更容易。有些东西,我已经非常接近找到强迫我的一个文本框的方式比我想要的更窄。通过构建新的母版页,我解决了这个问题。但我同时在我的代码中引入了一个行为问题。
一旦我按照我想要的方式查看页面,我发现我在页面上遇到了asp:GridView的问题。我在GridView中创建了一个列,该列基于位于模板字段中的未绑定的Checkbox功能。
<asp:TemplateField HeaderText="Tag" ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:CheckBox runat="server" ID="TagRowChkBx" />
</ItemTemplate>
</asp:TemplateField>
在执行新的自定义母版页以修复布局问题之前,这些复选框将保留其检查,直到手动取消选中它们。在介绍新的母版页后,检查&#39;使用选择后离开。我读了这些复选框,以确定我想要批量影响更改的行。
我希望功能上恢复到剩余检查状态,直到用户选择取消选中它们。
以下是导致批量取消选中的代码(母版页更改的意外后果):
protected void EditSelctedBtn_Click(object sender, EventArgs e)
{
//Read the column select drop down List into Local Varriables
String SelectedColumnItem = ColumnSelectDDL.SelectedItem.ToString();
String SelectedColumnValue = ColumnSelectDDL.SelectedValue.ToString();
// Caputre the checked rows to List
List<int> EditRows = new List<int>();
List<string> recordnumber = new List<string>();
foreach (GridViewRow grv in ActVulListGV.Rows)
{
if (((CheckBox)grv.FindControl("TagRowChkBx")).Checked == true)
{
//get current row rowindex if checkbox in it is checked
EditRows.Add(grv.RowIndex);
//get the record number (RecID)
recordnumber.Add(grv.Cells[2].Text.ToString());
}
}
// Place the List in an array
int[] ERows = EditRows.ToArray();
// Check the DDL values to make sure that the user has made a selection Warn if not.
if (ColumnSelectDDL.SelectedValue == "Choose Column To Edit")
{
UserMessageLbl.ForeColor = System.Drawing.Color.Red;
UserMessageLbl.Font.Bold = true;
UserMessageLbl.Text = " *** You must choose a column to edit! ***";
mpePopUp.Show();
}
else
{
// If Ticket # was selected enable Ticket # Panel
if (ColumnSelectDDL.SelectedValue.ToString() == "TicketNumber")
{
EditTicketNumPnl.Visible = true;
EditTicketClosedPnl.Visible = false;
EditNotesPnl.Visible = false;
EditExceptionIDPnl.Visible = false;
TicketNumFocusTbx.Text = "No Reference Data";
}
// If Ticket Closed was selected enable Ticket Closed Panel
else if (ColumnSelectDDL.SelectedValue.ToString() == "TicketClosed")
{
EditTicketNumPnl.Visible = false;
EditTicketClosedPnl.Visible = true;
EditNotesPnl.Visible = false;
EditExceptionIDPnl.Visible = false;
TicketCldFocusTbx.Text = "";
}
// If Notes was selected enable Notes Panel
else if (ColumnSelectDDL.SelectedValue.ToString() == "Notes")
{
EditTicketNumPnl.Visible = false;
EditTicketClosedPnl.Visible = false;
EditNotesPnl.Visible = true;
EditExceptionIDPnl.Visible = false;
NotesFocusTbx.Text = "No Reference Data";
}
// If Exception ID was selected enable Exception ID Panel
else if(ColumnSelectDDL.SelectedValue.ToString() == "Exception_ID")
{
EditTicketNumPnl.Visible = false;
EditTicketClosedPnl.Visible = false;
EditNotesPnl.Visible = false;
EditExceptionIDPnl.Visible = true;
ExceptionIDFocusTbx.Text = "No Reference Data";
}
// format the popup and it's buttons
EditColMsgLbl.Font.Bold = true;
SelectedRowsMsgLbl.Font.Bold = true;
ColEditPnlExt.Show();
EditColLbl.Text = SelectedColumnItem;
SelectedRowsLbl.Text = "";
String divider = "";
int ticks = 0;
foreach (string record in recordnumber)
{
if (ticks > 0)
{
divider = ", ";
++ticks;
}
else
{
++ticks;
}
SelectedRowsLbl.Text += divider.ToString() + record;
}
}
}
思想?