我有網格視圖內的複選框列和頁面上的一個按鈕和一個嚮導控件..我需要在像這樣的按鈕單擊事件複選框validataion ....如果任何複選框未選中,我需要防止加載嚮導步驟2 ....但我沒能做到這一點gridview上的複選框驗證按鈕點擊
我將所有選中行到另一個gridview的,我是在設置的WizardStep:1
這是我的代碼...
protected void Update_Onclick(object sender, EventArgs args)
{
DataTable dt = null;
CheckBox chk;
foreach(GridViewRow gvrow in gvPR.Rows)
{
//chk = (CheckBox)(gvPR.Rows[i].Cells[0].FindControl("chkFru"));
chk = (CheckBox)gvrow.FindControl("chkFru");
if (chk.Checked == true)
{
dt = objCert.BuildCertInfo();
DataRow dr = dt.NewRow();
// HtmlInputHidden hdn = (HtmlInputHidden)(gvPR.Rows[i].Cells[0].FindControl("hdnFruId"));
HtmlInputHidden hdn = (HtmlInputHidden)gvrow.FindControl("hdnFruId");
string strFru = hdn.Value;
dr[Certificate.SYS_SERIAL_NUMBER] = strFru;
//get Fru info
dsInfo = objCert.GetFruInfo(strFru);
if (dsInfo == null)
{
setError(lblCertErr, Certificate.NO_SYS_INFO);
return;
}
dr[Certificate.SYS_PART_ID] = dsInfo.Tables[0].Rows[0]["part_id"].ToString();
dr[Certificate.SYS_PART_DESC] = dsInfo.Tables[0].Rows[0]["Part_desc"].ToString();
dr[Certificate.SYS_SERIAL_NUMBER] = dsInfo.Tables[0].Rows[0]["Serial_Number"].ToString();
dr[Certificate.LOC] = dsInfo.Tables[0].Rows[0]["Location"].ToString();
dt.Rows.Add(dr);
}
}
LoadWizStep2(dt);
}
和LoadWizStep2(DT)的方法
private void LoadWizStep2(DataTable dt)
{
try
{
wizController.ActiveStepIndex = 1;
GridView2.DataSource = dt;
GridView2.DataBind();
Session["FRU_INFO"] = dt;
}
catch (Exception ex)
{
throw ex;
}
}
,這是aspx頁面代碼
<table width="100%" cellpadding="0" cellspacing="0" style="background-color: White">
<tr style="width: 100%">
<td colspan="2" align="left">
<asp:GridView ID="gvPR" runat="server" AutoGenerateColumns="False" GridLines="None"
CellSpacing="1" CellPadding="1"
Width="100%" BorderWidth="0px"
AllowSorting="True"
PageSize="30"
CssClass="data responsive"
OnSorting="gvPR_Sort" OnRowDataBound="ItemCellsUpdate"
EmptyDataText="No Certificates found" SortedAscendingHeaderStyle-CssClass="tableHeaderLink">
<Columns>
<asp:TemplateField>
<HeaderTemplate>
<asp:CheckBox ID="chkCerts" OnCheckedChanged="chkCerts_CheckedChanged"
AutoPostBack="true" runat="server" />
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID="chkFru" OnCheckedChanged="chkFru_CheckedChanged" AutoPostBack="true" runat="server" /><input type="hidden" id="hdnFruId" runat="server"
value='<%# DataBinder.Eval(Container.DataItem, "Fru") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Fru" HeaderText="System Serial Number" SortExpression="Fru" />
<asp:BoundField DataField="SystemPartId" HeaderText="System Part Number" SortExpression="SystemPartId" />
<asp:BoundField DataField="SystemDesc" HeaderText="System Description" SortExpression="SystemDesc" />
<asp:BoundField DataField="Location" HeaderText="System Location" SortExpression="Location" />
</Columns>
<HeaderStyle Height="30px" HorizontalAlign="Center" />
<PagerSettings Visible="False" />
</asp:GridView>
</td>
</tr>
</table>
如果複選框沒有被選中,我需要停下來進入下頁..我怎麼能我解決這個問題....
將任何一個,請在此
爲什麼你總是調用LoadWizStep2(DT);爲什麼不能通過標記添加一個條件來檢查這些複選框是否被選中? – 2014-10-31 12:46:26