前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >drop in session_drop constraint

drop in session_drop constraint

作者头像
全栈程序员站长
发布2022-09-27 10:25:10
5540
发布2022-09-27 10:25:10
举报
文章被收录于专栏:全栈程序员必看

//aspx <asp:Repeater ID=”Repeater1″ runat=”server” OnItemDataBound=”Repeater1_ItemDataBound”> <ItemTemplate> <asp:Label ID=”Label1″ runat=”server” Text='<%# DataBinder.Eval(Container.DataItem, “au_id” ) %>’></asp:Label> <asp:DropDownList ID=”DropDownList1″ runat=”server”> </asp:DropDownList> <br /> </ItemTemplate> </asp:Repeater>

//aspx.cs protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { SqlConnection cn = new SqlConnection(@”Server=.\SQLEXPress;uid=sa;pwd=password;Database=Pubs”); string strSQL = “select * from authors”; SqlCommand cmd = new SqlCommand(strSQL, cn); cn.Open(); SqlDataReader dr = cmd.ExecuteReader(); Repeater1.DataSource = dr; Repeater1.DataBind(); dr.Close(); cn.Close(); } } protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e) { Label label1; DropDownList dropDownList1; if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { label1 = (Label)e.Item.FindControl(“label1”); dropDownList1 = (DropDownList)e.Item.FindControl(“dropDownList1”); SqlConnection cn = new SqlConnection(@”Server=.\SQLEXPress;uid=sa;pwd=password;Database=Pubs”); string strSQL = “select title_id from titleauthor where au_id = ‘” + label1.Text + “‘”; SqlCommand cmd = new SqlCommand(strSQL, cn); cn.Open(); SqlDataReader dr = cmd.ExecuteReader(); dropDownList1.DataSource = dr; dropDownList1.DataTextField = “title_id”; dropDownList1.DataBind(); dr.Close(); cn.Close(); } }

发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/183930.html原文链接:https://javaforall.cn

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
命令行工具
腾讯云命令行工具 TCCLI 是管理腾讯云资源的统一工具。使用腾讯云命令行工具,您可以快速调用腾讯云 API 来管理您的腾讯云资源。此外,您还可以基于腾讯云的命令行工具来做自动化和脚本处理,以更多样的方式进行组合和重用。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档