如何从链接按钮存储值并将其分配给另一页面上的文本框

时间:2018-04-27 10:42:07

标签: c# asp.net

我正在制作一个电影项目并且我坚持这个:当我点击特定的小时时,我希望向我显示预订页面并使用特定小时自动完成小时文本框还有电影的名字。

以下是我的代码和截图:

ArrayList difuzList = new ArrayList();

    if (!IsPostBack)
    {
        difuzList = Conectare.GetZi("%");
    }
    else
    {
        difuzList = Conectare.GetZi(DropDownList1.SelectedValue);
    }
    StringBuilder sb = new StringBuilder();

    foreach (Difuzare difuzare in difuzList)
    {
        sb.Append(string.Format(@"<table class='filmTabel1'>
        <tr>
              <td><a runat='server' id='numeFil'>{0}</a></td>
              <td><a runat='server' id='oraD1' href='Rezervari.aspx'>{1}</a></td>
              <td><a runat='server' id='oraD2' href='Rezervari.aspx'>{2}</a></td>
              <td><a runat='server' id='oraD3' href='Rezervari.aspx'>{3}</a></td>
              <td><a runat='server' id='oraD4' href='Rezervari.aspx'>{4}</a></td>
        </tr>

    </table>", difuzare.Nume_film,difuzare.Ora1, difuzare.Ora2, difuzare.Ora3, difuzare.Ora4));
        labeloutPr.Text = sb.ToString();

    }

Hour schedule

This is the reservation page

1 个答案:

答案 0 :(得分:0)

您可以执行以下操作:

ArrayList difuzList = new ArrayList();

if (!IsPostBack)
{
    difuzList = Conectare.GetZi("%");
}
else
{
    difuzList = Conectare.GetZi(DropDownList1.SelectedValue);
}
StringBuilder sb = new StringBuilder();

foreach (Difuzare difuzare in difuzList)
{
    sb.Append(string.Format(@"<table class='filmTabel1'>
    <tr>
          <td><a runat='server' id='numeFil'>{0}</a></td>
          <td><a runat='server' id='oraD1' href='Rezervari.aspx?hour={1}'>{1}</a></td>
          <td><a runat='server' id='oraD2' href='Rezervari.aspx?hour={2}'>{2}</a></td>
          <td><a runat='server' id='oraD3' href='Rezervari.aspx?hour={3}'>{3}</a></td>
          <td><a runat='server' id='oraD4' href='Rezervari.aspx?hour={4}'>{4}</a></td>
    </tr>

</table>", difuzare.Nume_film,difuzare.Ora1, difuzare.Ora2, difuzare.Ora3, difuzare.Ora4));
    labeloutPr.Text = sb.ToString();

}

然后在预订页面中检索并确定您的小时(假设textboxHour是您的文本框控件):

textboxHour.Text = Request.QueryString["hour"];