0

我想通过多个步骤在 asp:wizard 中自动收集所有信息(即控制值)。怎么做?我找到了一个有趣的链接,但它似乎无法正常工作:只是关于当前步骤的一些信息:http: //msdn.microsoft.com/en-us/library/yt340bh4 (v=vs.80).aspx

foreach (Control c in Page.Controls)
{
    foreach (Control childc in c.Controls)
    {
        if (childc is Label)
        {
            lblTitre0.Text += ((Label)childc).Text + ",";
        }
    }
}

lblTitre0 (asp:label) 中没有显示数据

4

1 回答 1

0

试试这个

<asp:Wizard runat="server" ID="mainWizard">
 <WizardSteps>
  <asp:WizardStep>
   <asp:Label runat="server" ID="lbl1" Text="Label one" />
  </asp:WizardStep>
  <asp:WizardStep>
   <asp:Label runat="server" ID="lbl2" Text="Label two" />
  </asp:WizardStep>
 </WizardSteps>
</asp:Wizard>
<asp:Button runat="server" ID="btnGetall" Text="Get All controls" 
            OnClick="btn_Click" />
<br />
<asp:Label runat="server" ID="lblResult" />

protected void btn_Click(object sender, EventArgs e)
{
   foreach (WizardStep step in mainWizard.WizardSteps)
   {
     foreach (Control cntrl in step.Controls)
     {
        if (cntrl is Label)
          lblResult.Text += ((Label)cntrl).Text + ",";
     }
    }
}
于 2012-11-02T14:31:01.303 回答