<asp:DataList ID="DataList1" runat="server">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:DropDownList ID="ddlLang" runat="server">
<asp:ListItem Text="en" Value="epaper_en.htm"></asp:ListItem>
<asp:ListItem Text="tw" Value="epaper_tw.htm"></asp:ListItem>
<asp:ListItem Text="es" Value="epaper_es.htm"></asp:ListItem>
<asp:ListItem Text="fr" Value="epaper_fr.htm"></asp:ListItem>
<asp:ListItem Text="de" Value="epaper_de.htm"></asp:ListItem>
</asp:DropDownList>
<asp:Button ID="btnGo" runat="server" Text="Go" OnClick="btnGo_Click" />
</ItemTemplate>
</asp:DataList>
protected void btnGo_Click(object sender, EventArgs e)
{
try
{
DataListItem dli = (sender as Button).NamingContainer as DataListItem;
if (dli != null)
{
#region Get Label Text
Label lab = dli.FindControl("Label1") as Label;
if (lab != null)
Response.Write(lab.Text);
#endregion
#region Get TextBox
TextBox tbx = dli.FindControl("TextBox1") as TextBox;
if (tbx != null)
Response.Write(tbx.Text);
#endregion
#region Get DropDownList Value
DropDownList ddl = dli.FindControl("ddlLang") as DropDownList;
if (ddl != null)
ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Epaper", "window.open('" + ResolveUrl(ddl.SelectedValue) + "','_blank')", true);
#endregion
}
}
catch (Exception ex)
{
throw ex;
}
}
2013年6月4日 星期二
C# DataList取得ItemTemplate欄位值
[C#]DataList取得ItemTemplate欄位值
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言