<i id='f6BVa'><tr id='f6BVa'><dt id='f6BVa'><q id='f6BVa'><span id='f6BVa'><b id='f6BVa'><form id='f6BVa'><ins id='f6BVa'></ins><ul id='f6BVa'></ul><sub id='f6BVa'></sub></form><legend id='f6BVa'></legend><bdo id='f6BVa'><pre id='f6BVa'><center id='f6BVa'></center></pre></bdo></b><th id='f6BVa'></th></span></q></dt></tr></i><div id='f6BVa'><tfoot id='f6BVa'></tfoot><dl id='f6BVa'><fieldset id='f6BVa'></fieldset></dl></div>
<tfoot id='f6BVa'></tfoot><legend id='f6BVa'><style id='f6BVa'><dir id='f6BVa'><q id='f6BVa'></q></dir></style></legend>

<small id='f6BVa'></small><noframes id='f6BVa'>

        <bdo id='f6BVa'></bdo><ul id='f6BVa'></ul>

      1. 访问中继器控件中的文本框

        时间:2023-06-09
          • <small id='Zj2CH'></small><noframes id='Zj2CH'>

          • <tfoot id='Zj2CH'></tfoot>
            <legend id='Zj2CH'><style id='Zj2CH'><dir id='Zj2CH'><q id='Zj2CH'></q></dir></style></legend>

          • <i id='Zj2CH'><tr id='Zj2CH'><dt id='Zj2CH'><q id='Zj2CH'><span id='Zj2CH'><b id='Zj2CH'><form id='Zj2CH'><ins id='Zj2CH'></ins><ul id='Zj2CH'></ul><sub id='Zj2CH'></sub></form><legend id='Zj2CH'></legend><bdo id='Zj2CH'><pre id='Zj2CH'><center id='Zj2CH'></center></pre></bdo></b><th id='Zj2CH'></th></span></q></dt></tr></i><div id='Zj2CH'><tfoot id='Zj2CH'></tfoot><dl id='Zj2CH'><fieldset id='Zj2CH'></fieldset></dl></div>

                <tbody id='Zj2CH'></tbody>
                <bdo id='Zj2CH'></bdo><ul id='Zj2CH'></ul>

                1. 本文介绍了访问中继器控件中的文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我能想到的所有方法看起来都非常老套.什么是正确的方法,或者至少是最常见的方法?

                  All the ways I can think to do this seem very hackish. What is the right way to do this, or at least most common?

                  我正在从 LINQ-to-SQL 查询中检索一组图像,并将其和一些其他数据数据绑定到转发器.我需要为转发器中的每个项目添加一个文本框,让用户更改每个图像的标题,非常类似于 Flickr.

                  I am retrieving a set of images from a LINQ-to-SQL query and databinding it and some other data to a repeater. I need to add a textbox to each item in the repeater that will let the user change the title of each image, very similar to Flickr.

                  如何访问中继器控件中的文本框并知道该文本框属于哪个图像?

                  这是转发器控件的外观,带有一个提交按钮,可以更新 Linq-to-SQL 中的所有图像行:

                  Here is what the repeater control would look like, with a submit button which would update all the image rows in Linq-to-SQL:

                  替代文字 http://casonclagg.com/layout.jpg

                  此代码有效

                  只要确保你不会像我一样通过在 if(!Page.IsPostBack) 之外绑定来破坏你的价值观.哎呀.

                  Just make sure you don't blow your values away by Binding outside of if(!Page.IsPostBack) like me.. Oops.

                  <asp:Repeater ID="Repeater1" runat="server">
                      <ItemTemplate>
                          <div class="itemBox">
                              <div class="imgclass">
                                  <a title='<%# Eval("Name") %>' href='<%# Eval("Path") %>' rel="gallery">
                                      <img alt='<%# Eval("Name") %>' src='<%# Eval("Path") %>' width="260" />
                                  </a>
                              </div>
                              <asp:TextBox ID="TextBox1" Width="230px" runat="server"></asp:TextBox>
                          </div>
                      </ItemTemplate>
                  </asp:Repeater>
                  

                  并提交点击:

                  protected void Button1_Click(object sender, EventArgs e)
                  {
                      foreach (RepeaterItem item in Repeater1.Items)
                      {
                          TextBox txtName = (TextBox)item.FindControl("TextBox1");
                          if (txtName != null)
                          {
                              string val = txtName.Text;
                              //do something with val
                          }
                      }
                  }
                  

                  推荐答案

                  你有没有尝试过类似点击按钮的操作:-

                  Have you tried something like following on the button click:-

                  foreach (RepeaterItem item in Repeater1.Items)
                  {
                        TextBox txtName= (TextBox)item.FindControl("txtName");
                        if(txtName!=null)
                        {
                        //do something with txtName.Text
                        }
                        Image img= (Image)item.FindControl("Img");
                        if(img!=null)
                        {
                        //do something with img
                        }
                  }
                  

                  /* 其中txtName和Img分别是repeater中的文本框和图片控件的Id.*/

                  /* Where txtName and Img are the Ids of the textbox and the image controls respectively in the repeater.*/

                  希望这会有所帮助.

                  这篇关于访问中继器控件中的文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何以线程安全的方式将控制台程序的输出重定向到文本框? 下一篇:WPF 文本框的验证规则

                  相关文章

                      <bdo id='cPWTg'></bdo><ul id='cPWTg'></ul>
                    <legend id='cPWTg'><style id='cPWTg'><dir id='cPWTg'><q id='cPWTg'></q></dir></style></legend>

                      <tfoot id='cPWTg'></tfoot>
                      <i id='cPWTg'><tr id='cPWTg'><dt id='cPWTg'><q id='cPWTg'><span id='cPWTg'><b id='cPWTg'><form id='cPWTg'><ins id='cPWTg'></ins><ul id='cPWTg'></ul><sub id='cPWTg'></sub></form><legend id='cPWTg'></legend><bdo id='cPWTg'><pre id='cPWTg'><center id='cPWTg'></center></pre></bdo></b><th id='cPWTg'></th></span></q></dt></tr></i><div id='cPWTg'><tfoot id='cPWTg'></tfoot><dl id='cPWTg'><fieldset id='cPWTg'></fieldset></dl></div>

                      <small id='cPWTg'></small><noframes id='cPWTg'>