在送出之前將 DataList 的 Items 使用迴圈取出
HTML:
<form id="form1" runat="server"> <asp:DataList ID="DataList1" runat="server" Width="99.9%" RepeatDirection="Vertical"> <ItemStyle BorderWidth="1" /> <ItemTemplate> <asp:HiddenField ID="hifDlobjectype_code" runat="server" Value="A1234" /> </ItemTemplate> </asp:DataList> <asp:Button ID="btnSubmit" runat="server" Text="送出" Width="100px" OnClick="btnSubmit_Click" /> </form>
C#:
protected void btnSubmit_Click(object sender, EventArgs e) { try { DataList dl = DataList1; foreach (DataListItem dli in dl.Items) { string hifDlobjectype_code = ((HiddenField)dli.FindControl("hifDlobjectype_code")).Value; } } catch (Exception) { throw; } }
沒有留言:
張貼留言