巧用DataList 操作图片选取传值功能

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="SJDefaultSerch.aspx.cs" Inherits="Provide_SjDesign_SJDefaultSerch" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Design serch</title>
    <link href="../../css.css" rel="stylesheet" type="text/css" />
   <script type="text/javascript" src="../../Celend/popcalendar.js"></script>
   <script type="text/javascript" src="../../WebDisk_/photoJS.js"></script>
   <script type="text/javascript">
      function closese()
      {
//      alert("123");
      window.location.href="SJDefault.aspx";
      }
   </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <table style="width: 812px; height: 460px">
            <tr>
                <td style="width: 100%; height:10%">
                    架别:<asp:DropDownList ID="Drpsextype" runat="server" Width="60px">
                        <asp:ListItem></asp:ListItem>
                        <asp:ListItem>男性</asp:ListItem>
                        <asp:ListItem>女性</asp:ListItem>
                        <asp:ListItem>儿童</asp:ListItem>
                        <asp:ListItem>中性</asp:ListItem>
                    </asp:DropDownList>款式:<asp:DropDownList ID="Drpkstype" runat="server" Width="60px">
                        <asp:ListItem></asp:ListItem>
                        <asp:ListItem>时尚</asp:ListItem>
                        <asp:ListItem>传统</asp:ListItem>
                        <asp:ListItem>复古</asp:ListItem>
                        <asp:ListItem>运动</asp:ListItem>
                    </asp:DropDownList>
                     架类:<asp:DropDownList ID="Drpjltype" runat="server" Width="60px">
                        <asp:ListItem></asp:ListItem>
                        <asp:ListItem>光学</asp:ListItem>
                        <asp:ListItem>太阳</asp:ListItem>
                        <asp:ListItem>老花</asp:ListItem>
                    </asp:DropDownList>
                     材质:<asp:DropDownList ID="Drpcztype" runat="server" Width="60px">
                        <asp:ListItem></asp:ListItem>
                        <asp:ListItem>板材</asp:ListItem>
                        <asp:ListItem>金属</asp:ListItem>
                        <asp:ListItem>塑胶</asp:ListItem>
                        <asp:ListItem>TR90</asp:ListItem>
                        <asp:ListItem>钛</asp:ListItem>
                    </asp:DropDownList> &nbsp;关键字:
                    <asp:TextBox ID="Tbgjz" runat="server"></asp:TextBox>
                    &nbsp;&nbsp;<asp:Button ID="Btserch" runat="server" Text="查询" Width="41px" OnClick="Btserch_Click" /> &nbsp;<asp:Button ID="Btaddlist" runat="server" Text="加入列表" Width="60px" OnClick="Btaddlist_Click" />
                    &nbsp;
                    <input id="Button1" type="button" value="关闭"  οnclick="closese()"/>
                    &nbsp;
                </td>
            </tr>
            <tr>
                <td style="width: 100%; height:90%" >
 <div style="margin:auto; padding-top:0px; width: 100%; height:100% ">
    <asp:DataList ID="DataList1" runat="server" RepeatColumns="4" Width="99%" >
            <ItemTemplate><div style="width:160px;margin:auto;height:120px;border:1px solid gray;">
            <div>
           <img  alt="" style="margin:auto;border:none;padding:5px 5px 5px 5px;" src="<%#Eval("SmallPhoto")%>" οnclick="PhotoShow.url='<%#Eval("SmallSmallPic")%>' ;PhotoShow.PhotoClick();"  />
            </div>
        </div>
        <div style="color:Gray;text-align:Center;height:20px;"><input type="checkbox" id="chkDo" runat="server" name="chk" value='<%# Eval("listid") %>' />
<%#Eval("Name") %></div>
        </ItemTemplate>
    </asp:DataList>
<div style="margin:auto;height:20px;padding:0px;text-align:right;padding:0px; width: 798px;">
<br/>
<asp:LinkButton ID="lbnPrevPage" runat="server" CommandName="prev" OnCommand="Page_OnClick " OnClientClick='setTab("one",2,2)' >上一页</asp:LinkButton>
<asp:Label ID="lbCurrentPage" runat="server" Text=""></asp:Label>
&nbsp;&nbsp;<asp:Label ID="lbTotal" runat="server" Text=""></asp:Label>
<asp:LinkButton ID="lbnNextPage" runat="server" CommandName="next" OnCommand="Page_OnClick " OnClientClick='setTab("one",2,2)' >下一页</asp:LinkButton>
&nbsp;&nbsp;跳转至第<asp:DropDownList ID="lstPage" runat="server" OnSelectedIndexChanged="lstPage_SelectedIndexChanged1" AutoPostBack="True" >
    </asp:DropDownList>页&nbsp;&nbsp;&nbsp; 
</div>
</div>
                </td>
            </tr>
        </table>
   
    </div>
    </form>
</body>
</html>

 

以上是html 代码

以下是对  CheckBox 取值。

 protected void Btaddlist_Click(object sender, EventArgs e)
    {
        string num = "";
        foreach (Control c in DataList1.Controls)
        {
            //CheckBox chk = (CheckBox)c.FindControl("chkDo");  此只能取服务器控件的值
           HtmlInputCheckBox chk = (HtmlInputCheckBox)c.FindControl("chkDo"); 此可以取回html控件的值
           if (chk.Checked)
                num += chk.Value+ ",";
        }
        Response.Write("<script>alert('" + num + "')</script>");
    }

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值