lz意思是说灵活到你脑子里浮现出第几行
textbox就会出现该行的值要么点击一行可以赋值
要么你指定,既然你指定你起码还得有地方输入吧你怎么总是不明白呢

解决方案 »

  1.   

    不好意思,可能说我表达的有问题。我想这样操作,,首先我点击一个textbox,然后点击一下gridview中的一列,实现的效果就是这个textbox里的值就是刚才点击的gridview那一行的值。
      

  2.   

    这个貌似也很简单啊.
    在DataBound事件中给每列一个单击事件..
    然后读取列值,输出到javascript函数的参数中,
    然后写个js脚本把传递过来的参数值再赋给相应的TextBox就可以了
      

  3.   

    这个貌似也很简单啊. 
    在DataBound事件中给每列一个单击事件.. 
    然后读取列值,输出到javascript函数的参数中, 
    然后写个js脚本把传递过来的参数值再赋给相应的TextBox就可以了//不是相应的,而是我想任意的。
      

  4.   

     protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
        {
            msg.Text = "";
            index_id  = int.Parse(this.GridView1.Rows[e.NewEditIndex].Cells[2].Text.Trim());
            this.TextBox1.Text = this.GridView1.Rows[e.NewEditIndex].Cells[3].Text.Trim();
            string grade = this.GridView1.Rows[e.NewEditIndex].Cells[5].Text.Trim();
            switch (grade)
            {
                case "super":
                    this.DropDownList1.SelectedValue = "super";
                    break;
                case "junior":
                    this.DropDownList1.SelectedValue = "junior";
                    break;
                default:
                    this.DropDownList1.SelectedValue = "junior";
                    break;
            }
        }这是在一个编辑列给Textbox赋值!如果只是想单击某一列赋值,选 对应的事件处理一下就可以了!很简单!
      

  5.   

    你弄错了啊。我的那些很多的textbox不是在gridview里面。。
      

  6.   

    小丫,我怎么感觉你都不上路呀!你觉得我的是在gridview里面的吗?算了出去玩去了!
      

  7.   

    在它的ItemDataBound事件里添加如下代码: If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
                e.Item.Attributes.Add("onmouseover", "this.style.backgroundColor='Fuchsia';this.style.cursor='hand'")
                e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='#f5f5dc';this.style.cursor='hand'")
                e.Item.Attributes.Add("onclick", "Txt003.value='" & e.Item.Cells(0).Text.ToString _
                            & "';Ddl002.value='" & e.Item.Cells(1).Text.ToString _
                            & "';Txt020.value='2'" _
                            & ";Txt004.value='" & e.Item.Cells(2).Text.ToString _
                            & "';Txt005.value='" & e.Item.Cells(3).Text.ToString _
                            & "';Txt006.value='" & e.Item.Cells(4).Text.ToString _
                            & "';Txt007.value='" & e.Item.Cells(5).Text.ToString _
                            & "';Txt008.value='" & e.Item.Cells(6).Text.ToString _
                            & "';Txt009.value='" & e.Item.Cells(7).Text.ToString _
                            & "';Txt010.value='" & e.Item.Cells(8).Text.ToString _
                            & "';Txt011.value='" & e.Item.Cells(9).Text.ToString _
                            & "';Txt012.value='" & e.Item.Cells(0).Text.ToString _
                            & "';Lbl009.value='<< 変 更 >>'" _
                            & ";Ddl001.disabled=true" _
                            & ";Txt001.readOnly=true" _
                            & ";Txt002.readOnly=true" _
                            & ";Ddl002.disabled=false" _
                            & ";Txt005.disabled=false" _
                            & ";Txt009.disabled=false" _
                            & ";Txt010.disabled=false" _
                            & ";Txt011.disabled=false" _
                            & ";Txt001.value='" & e.Item.Cells(10).Text.ToString _
                            & "';Ddl001.value='" & e.Item.Cells(11).Text.ToString _
                            & "';Txt002.value='" & e.Item.Cells(12).Text.ToString _
                            & "';Txt013.value='" & e.Item.Cells(10).Text.ToString _
                            & "';Txt014.value='" & e.Item.Cells(11).Text.ToString _
                            & "';Txt015.value='" & e.Item.Cells(12).Text.ToString _
                            & "';Txt016.value='" & e.Item.Cells(13).Text.ToString _
                            & "'")
      

  8.   

    通过gridview的行id使用url进行传值,url地址是当前页就可以呀
      

  9.   

    你的意思是不是说textbox都要是可以选择的,而不是固定的,可以这样实现
    注意textbox是html控件

    服务器端:
    protected void GridView1_RowDataBound ( object sender, GridViewRowEventArgs e )
        {
            if ( e.Row.RowType == DataControlRowType.DataRow )
            {
                e.Row.Attributes.Add ( "onclick", "RowClick(this);" );
            }
        }
    客户端:
    <input id="Text1" type="text" onclick="SelectText(this);" />
    <input id="Text2" type="text" onclick="SelectText(this);" />
    <script>
          var textObj;
          function RowClick(row)
          {
             textObj.value = row.cells[0].innerText;
          }
          function SelectText(obj)
          {
             textObj = obj;
          }
    </script>
      

  10.   

    为了防止你没有选择textbox出错可以加判断
    function RowClick(row)
          {
             if(textObj)
             {
                 textObj.value = row.cells[0].innerText;
             }
          }