第一次加载表格默认选中一行,第一个文本框显示的值是    表的1行1列
点击表的第4行,   显示的值还是,表的1行1列     正确结果是4.
从代码中我能得到对应的值,就是对应文本框的值不更新。(如:上图)表格的值知道,怎么获取.
有什么好的方法,能点击对应的行显示对应文本框的值.

解决方案 »

  1.   

    你数据行都能获得了 那就直接设置文本框对象的Text呗文本框对象你找不到?
      

  2.   

    如果是GridView,用c#处理的话, 至少需要重新绑定一下,绑定后定位到当前行
      

  3.   

    this.text1.text=gridview1.cell(4,1),....
      

  4.   

    文本框的id获取不了吧?貌似你用的是dev的控件,在网页中查看源文件,看看文本框的id 是什么,把只赋给它就可以了 
      

  5.   

    5楼好眼力,是用Dev做的,javascript不是很熟悉,希望有代码,我补充一下右边表的值显示在,左边对应的值。比较id 是num1,num2等等,能不能  写一个让我看下。
      

  6.   

    这个效果没试过,我试试去,你应该是用的repeater吧
      

  7.   

    左边是detailView,,右边是repeater吗
    那要得到id,就能显示到detailView上了吧
    在加上 updatePanel无刷新行了,,
      

  8.   

    我还是贴下code
        /// <summary>
        /// 绑定线路表xml
        /// </summary>
        void bindLine(string shapeType)
        {
            dsLine= new DataSet();
            dsLine.ReadXml(Server.MapPath(xmlpath));
            this.gridLine.DataSource = dsLine.Tables[shapeType];
            this.gridLine.DataBind();
        }    protected void gridLine_FocusedRowChanged(object sender, EventArgs e)
        {
            key = gridLine.FocusedRowIndex;//获得选中行的索引
            string ID = this.gridLine.GetRowValues(key, "ID").ToString();
            nudCONDUCTD.Text = dsLine.Tables["LINE_PARA"].Rows[key][0].ToString();
            
           
        }能获得值。经过 调试 点哪行,能得到对应的值,如:点第4行,程序显示nudCONDUCTD.Text=4正解
    就是控件没刷新,问大家有什么好方法
      

  9.   


        <script type="text/javascript" language="javascript">
                function GetId(id){
             document.getElementById('<%=TextBox1.ClientID %>').value=id;
             location.href="Text.aspx?id="+id;
                }
        </script>    <div>
            <div style="float: left; width: 150px;">
                <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                <asp:DetailsView ID="DetailsView1" runat="server" Height="50px" Width="125px">
                </asp:DetailsView>
            </div>
            <div style="float: left; width: 450px;">
                <table width="400" style="text-align: center;" border="1" cellpadding="5" cellspacing="0">
                    <tr>
                        <th width="100">
                            房间号</th>
                        <th width="110">
                            客户类型</th>
                        <th width="90">
                            床位数</th>
                        <th width="90">
                            客人数</th>
                        <th width="90">
                            状态</th>
                    </tr>
                    <asp:Repeater ID="Repeater1" runat="server" OnItemDataBound="Repeater1_ItemDataBound">
                        <ItemTemplate>
                            <tr id="row" runat="server">
                                <td>
                                    <%# Eval("number")%>
                                </td>
                                <td>
                                    <%# Eval("type.typename")%>
                                </td>
                                <td>
                                    <%# Eval("bebnumber")%>
                                </td>
                                <td>
                                    <%# Eval("guestnumber")%>
                                </td>
                                <td>
                                    <%# Eval("state.StateName")%>
                                </td>
                            </tr>
                        </ItemTemplate>
                    </asp:Repeater>
                </table>
            </div>
        </div>protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                this.Repeater1.DataSource = RoomManager.GetAllRoom();
                Repeater1.DataBind();
                if (Request.QueryString["id"] != null) {
                    int id = Convert.ToInt32(Request.QueryString["id"]);
                    List<Room> list = new List<Room>();
                    list.Add(RoomManager.GetRoomById(id));
                    this.DetailsView1.DataSource = list;
                    this.DetailsView1.DataBind();
                }
            }
        }
        protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            HtmlTableRow row = (HtmlTableRow)e.Item.FindControl("row");     
            if (row != null)
            {
                row.Attributes.Add("onmouseover", "a=this.style.backgroundColor;this.style.backgroundColor='#6699ff'");
                row.Attributes.Add("onmouseout", "this.style.backgroundColor=a");
                Room rowv = (Room)e.Item.DataItem;
                int rid = rowv.RoomId;
                row.Attributes.Add("onclick", "GetId('" + rid + "')");
            }
        }
    希望对你有点帮助,,,,
      

  10.   

    谢谢10楼的回复,我左边是PageControl  右边是ASPxGridView.我开始也是尝试用  单向绑定(Eval),双向绑定(Bind) 这种表达式去做 。可是不行。
      

  11.   

    js取值,js给input赋值,用jquery方便点
      

  12.   

    1.是文本框没有刷新?
    2.文本框在事件里重新赋值了之后,在page_load事件里又再次被赋初始值,导致文本框“貌似”未刷新?
      

  13.   

    19楼所说的,我的哪种不存在这种情况,假设是哪种情况出现,加个 !Ispostback 非页面回发就可以了。17楼说的,我觉得能解决哪个问题,对html 里面的代码不是很熟悉,能贴下你的code吗
      

  14.   

    没有完全看楼主的回复,如果是因为Gridview绑定数据后,然后获取不了数据源是因为你在Page_Load事件里面绑定,在Page_Init里面绑定就可以了
      

  15.   

    有没有直接点的啊。给code,我给.