当前位置:编程学习 > C#/ASP.NET >>

在Repeater中怎么给select赋值

 <select name="nameBiddingProvince" class="validate[required]">  
                          
                                  <option value="0">全国</option>
                                      
                                  <option value="1">湖南</option>
                                      
                                  <option value="2">北京</option>
                                      
                                  <option value="3">天津</option>
                                      
                                  <option value="4">河南</option>
                                      
                                  <option value="5">河北</option>
                                      
                                  <option value="6">江苏</option>
                                      
                                  <option value="7">江西</option>
                                      
                                  <option value="8">云南</option>
                                      
                                  <option value="9">上海</option>
                                      
                                  <option value="10">湖北</option>
                                      
                                  <option value="11">广东</option>
                                      
                                  <option value="12">山西</option>
                                      
                                  <option value="13">辽宁</option>
                                      
                                  <option value="14">吉林</option>
                                      
                                  <option value="15">浙江</option>
                                      
                                  <option value="16">安徽</option>
                                      
                                  <option value="17">福建</option>
                                      
                                  <option value="18">山东</option>
                                      
                                  <option value="19">内蒙古</option>
                                      
                                  <option value="20">黑龙江</option>
                                      
                                  <option value="21">广西</option>
                                      
                                  <option value="22">海南</option>
                                      
                                  <option value="23">四川</option>
                                      
                                  <option value="24">重庆</option>
                                      
                                  <option value="26">贵州</option>
                                      
                                  <option value="27">易做图</option>
                                      
                                  <option value="28">陕西</option>
                                      
                                  <option value="29">甘肃</option>
                                      
                                  <option value="30">青海</option>
                                      
                                  <option value="31">宁夏</option>
                                      
                                  <option value="32">新疆</option>
                                      
                                  <option value="583">台湾</option>
                                      
                                  <option value="584">香港</option>
                                      
                                  <option value="585">澳门</option>
                                      
                          
                          </select>
我的option是用C#代码生成的加载的时候,我怎么将数据库存的数字重新与select关联起来呢?
--------------------编程问答-------------------- 不太明白LZ想表达什么? --------------------编程问答-------------------- 你加载的源码在哪里?可以改的 --------------------编程问答--------------------
引用 2 楼 hdhai9451 的回复:
你加载的源码在哪里?可以改的


-------------------------------=-------------
   <asp:Repeater  ID="repeater_zhongbiao" runat="server">
                        <ItemTemplate>
                        <tr>
                       <td style=" text-align:center;"><input type="checkbox" name="one" style=" float:left;" value="0"/><span>1</span><input type="hidden" name="nameID" value="<%#Eval("ID") %>" /></td>
                <td><input  type="text" name="namePack" value="<%#Eval("PackingSize") %>" /></td>
                  <td><input  type="text" name="nameBiddPrice" value="<%#Eval("BiddingPrice") %>" /></td>
                  <td>
                  <%
                     
                                                System.Data.DataTable dt = MySystem.Tools.PublicHelper.GetListModel("city", " AID,AName", " APid in(0,-1)",-1);
                      if (dt!=null)
                      {
                          if (dt.Rows.Count > 0)
                          {
                              int i = 0;
                          %>
                          <select name="nameBiddingProvince" class="validate[required]">  
                          <%
                              
                              foreach (System.Data.DataRow dr in dt.Rows)
                              {
                                                                                                      %>
                                  <option value="<%=dr[0]%>" tag="<%#Eval("BiddingProvince")%>"><%=dr[1].ToString() %></option>
                                      <%
                              }
                              
                         %>
                          
                          </select>
                          <%
                          }
                      }
                     

                     
                      
                       %>
                       </td>

<td><input type="text" size="100" name="nameBiddInfor" value="<%#Eval("BiddingInfor") %>" /></td>
                </tr>
                        </ItemTemplate>
                    </asp:Repeater>
                       <% }
---------------------------------
我是在前台拼的,当点击查看的时候,我希望 下拉框选中数据库存的值。 --------------------编程问答--------------------
引用 1 楼 zhanglong_longlong 的回复:
不太明白LZ想表达什么?

就是select选中的值与数据库保存的值绑定,我增加的时候,已经将值存到数据库了,存的是数字,
我加载的时候,用repeater,怎么将select绑定。
求指导啊。
补充:.NET技术 ,  ASP.NET
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,