Finding a Control Inside a Template
来源:互联网 发布:sql 外键关联查询 编辑:程序博客网 时间:2024/06/05 21:52
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<%@ Import Namespace="System.Data.SqlClient" %>
<html>
<script language="C#" runat="server">
void Page_Load(Object Src, EventArgs E ) {
if (!Page.IsPostBack) {
SqlConnection myConnection = new SqlConnection("server=(local)//NetSDK;database=pubs;Trusted_Connection=yes");
SqlDataAdapter myCommand = new SqlDataAdapter("select * from Titles where type='business'", myConnection);
DataSet ds = new DataSet();
myCommand.Fill(ds, "Titles");
MyDataList.DataSource = ds.Tables["Titles"].DefaultView;
MyDataList.DataBind();
}
}
void Submit_Click(Object Src, EventArgs E ) {
for (int i=0; i<MyDataList.Items.Count; i++) {
String isChecked = ((CheckBox) MyDataList.Items[i].FindControl("Save")).Checked.ToString();
Message.InnerHtml += "Item(" + i + "): " + isChecked + "<br>";
}
}
</script>
<body topmargin="0" leftmargin="0" marginwidth="0" marginheight="0">
<form runat="server">
<!-- #include virtual="/quickstart/aspplus/samples/webforms/customize/header.inc" -->
<ASP:DataList id="MyDataList" RepeatColumns="2" runat="server">
<ItemTemplate>
<table cellpadding=10 style="font: 10pt verdana">
<tr>
<td width=1 bgcolor="BD8672"/>
<td valign="top">
<img align="top" src='<%# DataBinder.Eval(Container.DataItem, "title_id", "/quickstart/aspplus/images/title-{0}.gif") %>' >
</td>
<td valign="top">
<b>Title: </b><%# DataBinder.Eval(Container.DataItem, "title") %><br>
<b>Category: </b><%# DataBinder.Eval(Container.DataItem, "type") %><br>
<b>Publisher ID: </b><%# DataBinder.Eval(Container.DataItem, "pub_id") %><br>
<b>Price: </b><%# DataBinder.Eval(Container.DataItem, "price", "$ {0}") %>
<p>
<asp:CheckBox id="Save" runat="server"/> <b>Save to Favorites</b>
</td>
</tr>
</table>
</ItemTemplate>
</ASP:DataList>
<p>
<div style="padding:0,15,0,15">
<input type="submit" Value="Update Favorites" OnServerClick="Submit_Click" runat="server"/>
</div>
<p>
<!-- #include virtual="/quickstart/aspplus/samples/webforms/customize/footer.inc" -->
</form>
<div style="font: 10pt verdana" EnableViewState="false" id="Message" runat="server"/>
</body>
</html>
&n
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<%@ Import Namespace="System.Data" %><%@ Import Namespace="System.Data.SqlClient" %>
<html>
<script language="C#" runat="server">
void Page_Load(Object Src, EventArgs E ) {
if (!Page.IsPostBack) {
SqlConnection myConnection = new SqlConnection("server=(local)//NetSDK;database=pubs;Trusted_Connection=yes");
SqlDataAdapter myCommand = new SqlDataAdapter("select * from Titles where type='business'", myConnection);
DataSet ds = new DataSet();
myCommand.Fill(ds, "Titles");
MyDataList.DataSource = ds.Tables["Titles"].DefaultView;
MyDataList.DataBind();
}
}
void Submit_Click(Object Src, EventArgs E ) {
for (int i=0; i<MyDataList.Items.Count; i++) {
String isChecked = ((CheckBox) MyDataList.Items[i].FindControl("Save")).Checked.ToString();
Message.InnerHtml += "Item(" + i + "): " + isChecked + "<br>";
}
}
</script>
<body topmargin="0" leftmargin="0" marginwidth="0" marginheight="0">
<form runat="server">
<!-- #include virtual="/quickstart/aspplus/samples/webforms/customize/header.inc" -->
<ASP:DataList id="MyDataList" RepeatColumns="2" runat="server">
<ItemTemplate>
<table cellpadding=10 style="font: 10pt verdana">
<tr>
<td width=1 bgcolor="BD8672"/>
<td valign="top">
<img align="top" src='<%# DataBinder.Eval(Container.DataItem, "title_id", "/quickstart/aspplus/images/title-{0}.gif") %>' >
</td>
<td valign="top">
<b>Title: </b><%# DataBinder.Eval(Container.DataItem, "title") %><br>
<b>Category: </b><%# DataBinder.Eval(Container.DataItem, "type") %><br>
<b>Publisher ID: </b><%# DataBinder.Eval(Container.DataItem, "pub_id") %><br>
<b>Price: </b><%# DataBinder.Eval(Container.DataItem, "price", "$ {0}") %>
<p>
<asp:CheckBox id="Save" runat="server"/> <b>Save to Favorites</b>
</td>
</tr>
</table>
</ItemTemplate>
</ASP:DataList>
<p>
<div style="padding:0,15,0,15">
<input type="submit" Value="Update Favorites" OnServerClick="Submit_Click" runat="server"/>
</div>
<p>
<!-- #include virtual="/quickstart/aspplus/samples/webforms/customize/footer.inc" -->
</form>
<div style="font: 10pt verdana" EnableViewState="false" id="Message" runat="server"/>
</body>
</html>
&n
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
- Finding a Control Inside a Template
- Selecting multiple checkboxes inside a GridView control
- Selecting multiple checkboxes inside a GridView control
- Custom Draw items inside a ListView Control
- Wrap a User Control inside a Web Part using WSPBuilder
- Finding a Component Interfaces
- Finding a lost dSYM
- Finding a string length
- A look inside blocks
- UITabBarController inside a UINavigationController
- Expert finding is a challenge
- Control 'ctl00_Menu1' of type 'Menu' must be placed inside a form tag with runat=server.
- Control 'GridView1' of type 'GridView' must be placed inside a form tag with runat=server
- A XHTML Template
- typedef on a template
- A general recursive template
- How to find child controls that are located in the template of a parent control
- A Look Inside JBoss Cache
- 用PHP来写记数器(详细介绍)
- WebGain and HP Collaborate to Bridge Java and .NET
- 基于mysql的bbs设计(五)
- Singleton Pattern in CSharp
- 6。bbsd和cq66服务器端改造
- Finding a Control Inside a Template
- PHP+DBM的同学录程序(5)
- String类使用的例子(3)
- PHP+DBM的同学录程序(3)
- 老外编的程序(四)--HashTable的使用示例
- PHP+DBM的同学录程序(4)
- 老外编的程序(五)--如何使用全球标识符(GUID)
- PHP+DBM的同学录程序(2)
- Office XP Charting Examples in asp.net