我很难弄清楚这一点。我不能很好地解释它,所以这里首先是一些 html/asp:
<%for(int i=0; i<getCountRows(); i++)
{
setLabelsFestivals(i);
%>
<form action="festival_details.aspx" method="post">
<table id="table_600px_border">
<tbody class="content_table_left" style='padding: 10px;'>
<tr>
<td class="content_table_300px content_table_left_up">
<div class="text_bold">
<asp:Label ID="nameFestival" runat="server"></asp:Label>
</div>
<asp:HiddenField ID="fest_id" runat="server" />
</td>
<td class="content_table_300px content_table_left_up_bottom">
<asp:Label ID="startDateFestival" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td class="content_table_left_up">
<asp:Label ID="locationFestival" runat="server"></asp:Label>
</td>
<td class="content_table_left_up">
<asp:Label ID="endDateFestival" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td class="content_table_left_up_bottom">
<asp:HyperLink ID="urlFestival" runat="server">Site</asp:HyperLink>
</td>
<td class="content_table_right_bottom">
<input type="submit" name="btnDetails" value="Details" />
</td>
</tr>
</tbody>
</table>
</form>
<% }
对于数据集中的每一行,使用一个简单的提交按钮动态创建一个表单。这就是后面代码中发生的事情
//This method makes sure that the correct labels are shown on the screen
protected void setLabelsFestivals(int positionDataSet)
{
//Checking if data is found for bands
if (getCountRows() > 0)
{
DateTime dtStartDate = Convert.ToDateTime(dataSetFestivals.Tables[0].Rows[positionDataSet]["fest_datum"].ToString());
DateTime dtEndDate = Convert.ToDateTime(dataSetFestivals.Tables[0].Rows[positionDataSet]["fest_einddatum"].ToString());
//Showing all festivals and its data
nameFestival.Text = dataSetFestivals.Tables[0].Rows[positionDataSet]["fest_naam"].ToString();
fest_id.Value = dataSetFestivals.Tables[0].Rows[positionDataSet]["fest_id"].ToString();
startDateFestival.Text = "Begindatum: " + dtStartDate.ToString("yyyy-MM-dd");
locationFestival.Text = "Locatie: " + dataSetFestivals.Tables[0].Rows[positionDataSet]["fest_locatie"].ToString();
endDateFestival.Text = "Einddatum: " + dtEndDate.ToString("yyyy-MM-dd");
urlFestival.NavigateUrl = "http://" + dataSetFestivals.Tables[0].Rows[positionDataSet]["fest_url"].ToString();
urlFestival.Target = "_blank";
}
}
那么,例如,我怎样才能在festival_details.aspx 中获取隐藏字段宽度 id“fest_id”的值?这是我尝试过的:
HttpContext variables = HttpContext.Current;
strFormIdFest = variables.Request["fest_id"];
但是,字符串 strFormIdFest 始终为空。我想这与clientId有关?