1
私はいくつかのAsp.netコードを次の表に継承しました。私は一歩一歩踏み出して、「悪い」として選択されたラジオボタンを見つけて、関連するコーン文字列を見つける必要があります。ここでのaspxコードは次のとおりです。値のために静的に作成されたラジオボタンリストをステップ実行する必要があります
<table class="checklistTable" id="checkListTable" cellpadding="0" cellspacing="0" runat="server">
<!-- start of visual checks -->
<tr>
<td colspan="4" class="sectionTitle">
Visual Checks
</td>
</tr>
<tr>
<td class="columnRadioPictures">
<asp:Image ID="Image1" runat="server" AlternateText="Ok" ImageUrl="../../images/checkmark.gif" />
<asp:Image ID="Image2" runat="server" AlternateText="Bad" ImageUrl="../../images/xmark.gif" />
<asp:Image ID="Image6" runat="server" AlternateText="N/A" ImageUrl="../../images/notapplicable.gif" />
</td>
<td class="columnText">
</td>
<td class="columnRadioPictures">
<asp:Image ID="Image3" runat="server" AlternateText="Ok" ImageUrl="../../images/checkmark.gif" />
<asp:Image ID="Image4" runat="server" AlternateText="Bad" ImageUrl="../../images/xmark.gif" />
<asp:Image ID="Image5" runat="server" AlternateText="N/A" ImageUrl="../../images/notapplicable.gif" />
</td>
<td class="columnText">
</td>
</tr>
<tr>
<td class="columnRadio">
<asp:RadioButtonList ID="VC_MfgManual" RepeatDirection="Horizontal" runat="server">
<asp:ListItem Value="Ok" Text="" />
<asp:ListItem Value="Bad" Text="" />
<asp:ListItem Value="N/A" Text="" />
</asp:RadioButtonList>
</td>
<td class="columnText">
MANUFACTURER'S MANUAL
</td>
<td class="columnRadio">
<asp:RadioButtonList ID="VC_Hoses" RepeatDirection="Horizontal" runat="server">
<asp:ListItem Value="Ok" Text="" />
<asp:ListItem Value="Bad" Text="" />
<asp:ListItem Value="N/A" Text="" />
</asp:RadioButtonList>
</td>
<td class="columnText">
HOSES
</td>
</tr>
<tr>
<td class="columnRadio">
<asp:RadioButtonList ID="VC_DataPlate" RepeatDirection="Horizontal" runat="server">
<asp:ListItem Value="Ok" Text="" />
<asp:ListItem Value="Bad" Text="" />
<asp:ListItem Value="N/A" Text="" />
</asp:RadioButtonList>
</td>
<td class="columnText">
DATA PLATE
</td>
<td class="columnRadio">
<asp:RadioButtonList ID="VC_TiresWheels" RepeatDirection="Horizontal" runat="server">
<asp:ListItem Value="Ok" Text="" />
<asp:ListItem Value="Bad" Text="" />
<asp:ListItem Value="N/A" Text="" />
</asp:RadioButtonList>
</td>
<td class="columnText">
TIRES/WHEELS
</td>
</tr>
<tr>
<td class="columnRadio">
<asp:RadioButtonList ID="VC_WarningDecals" RepeatDirection="Horizontal" runat="server">
<asp:ListItem Value="Ok" Text="" />
<asp:ListItem Value="Bad" Text="" />
<asp:ListItem Value="N/A" Text="" />
</asp:RadioButtonList>
</td>
<td class="columnText">
WARNING DECALS
</td>
<td class="columnRadio">
<asp:RadioButtonList ID="VC_Mirrors" RepeatDirection="Horizontal" runat="server">
<asp:ListItem Value="Ok" Text="" />
<asp:ListItem Value="Bad" Text="" />
<asp:ListItem Value="N/A" Text="" />
</asp:RadioButtonList>
</td>
<td class="columnText">
MIRRORS
</td>
</tr>
<tr>
<td class="columnRadio">
<asp:RadioButtonList ID="VC_OverheadGuard" RepeatDirection="Horizontal" runat="server">
<asp:ListItem Value="Ok" Text="" />
<asp:ListItem Value="Bad" Text="" />
<asp:ListItem Value="N/A" Text="" />
</asp:RadioButtonList>
</td>
<td class="columnText">
OVERHEAD GUARD
</td>
<td class="columnRadio">
<asp:RadioButtonList ID="VC_SeatBelt" RepeatDirection="Horizontal" runat="server">
<asp:ListItem Value="Ok" Text="" />
<asp:ListItem Value="Bad" Text="" />
<asp:ListItem Value="N/A" Text="" />
</asp:RadioButtonList>
</td>
<td class="columnText">
SEAT BELT
</td>
</tr>
<tr>
<td class="columnRadio">
<asp:RadioButtonList ID="VC_MastAssembly" RepeatDirection="Horizontal" runat="server">
<asp:ListItem Value="Ok" Text="" />
<asp:ListItem Value="Bad" Text="" />
<asp:ListItem Value="N/A" Text="" />
</asp:RadioButtonList>
</td>
<td class="columnText">
MAST AND BOOM ASSEMBLY
</td>
<td class="columnRadio">
<asp:RadioButtonList ID="VC_FireExtinguisher" RepeatDirection="Horizontal" runat="server">
<asp:ListItem Value="Ok" Text="" />
<asp:ListItem Value="Bad" Text="" />
<asp:ListItem Value="N/A" Text="" />
</asp:RadioButtonList>
</td>
<td class="columnText">
FIRE EXTINGUISHER
</td>
</tr>
<tr>
<td class="columnRadio">
<asp:RadioButtonList ID="VC_LiftChainRoller" RepeatDirection="Horizontal" runat="server">
<asp:ListItem Value="Ok" Text="" />
<asp:ListItem Value="Bad" Text="" />
<asp:ListItem Value="N/A" Text="" />
</asp:RadioButtonList>
</td>
<td class="columnText">
LIFT CHAINS/ROLLERS
</td>
<td class="columnRadio">
<asp:RadioButtonList ID="VC_FuelCap" RepeatDirection="Horizontal" runat="server">
<asp:ListItem Value="Ok" Text="" />
<asp:ListItem Value="Bad" Text="" />
<asp:ListItem Value="N/A" Text="" />
</asp:RadioButtonList>
</td>
<td class="columnText">
FUEL CAP
</td>
</tr>
<tr>
<td class="columnRadio">
<asp:RadioButtonList ID="VC_Forks" RepeatDirection="Horizontal" runat="server">
<asp:ListItem Value="Ok" Text="" />
<asp:ListItem Value="Bad" Text="" />
<asp:ListItem Value="N/A" Text="" />
</asp:RadioButtonList>
</td>
<td class="columnText">
FORKS/RAM
</td>
<td class="columnRadio">
<asp:RadioButtonList ID="VC_PropaneTank" RepeatDirection="Horizontal" runat="server">
<asp:ListItem Value="Ok" Text="" />
<asp:ListItem Value="Bad" Text="" />
<asp:ListItem Value="N/A" Text="" />
</asp:RadioButtonList>
</td>
<td class="columnText">
PROPANE TANK
</td>
</tr>
<tr>
<td class="columnRadio">
<asp:RadioButtonList ID="VC_HydraulicCylinders" RepeatDirection="Horizontal" runat="server">
<asp:ListItem Value="Ok" Text="" />
<asp:ListItem Value="Bad" Text="" />
<asp:ListItem Value="N/A" Text="" />
</asp:RadioButtonList>
</td>
<td class="columnText">
HYDRAULIC CYLINDERS
</td>
</tr>
</table>
私は背後に、次のコードを試してみましたが、ラジオボタンの値を読んでいないです:事前に
foreach (Control ctrl in checkListTable.Controls)
{
foreach (Control tblCell in ctrl.Controls)
{
foreach (Control radioBtn in tblCell.Controls)
{
strCtrl = radioBtn.GetType().ToString();
if (radioBtn is RadioButtonList)
{
RadioButtonList rbl = (RadioButtonList)ctrl;
for (int i = 0; i < rbl.Items.Count; i++)
{
if (rbl.Items[i].Value.ToString() == "Bad")
{
//get the text value of the column text
}
}
}
}
}
}
感謝を!