use javascript, for example:
<%@ Page Language="C#" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.SqlClient" %>
<script runat="server">    void Page_Load(object o, EventArgs e)
    {    string connstr = @"pwd=; UID=sa;Initial Catalog=pubs;Data Source=localhost";
    SqlConnection cnn=new SqlConnection(connstr);
    SqlDataAdapter da=
    new SqlDataAdapter("select * from authors", cnn);
    DataTable dt =new DataTable();
    da.Fill(dt);
    DataGrid1.DataSource = dt.DefaultView;
    DataGrid1.DataBind();    }</script>
<html>
<head>
</head>
<body>
    <form runat="server">
        <asp:DataGrid id="DataGrid1" runat="server" BackColor="#C0C000"></asp:DataGrid>
        <asp:TextBox id="txt1" runat="server" />
        <!-- Insert content here -->
    </form>
</body>
</html>
<script language="javascript">
function DataGrid1.onclick()
{
  document.getElementById("txt1").value = event.srcElement.innerText;
}
</script>

解决方案 »

  1.   

    如思归所说,脚本用document.all("txt1").value=event.srcElenment.innerText;也可以
      

  2.   

    一定是要通过赋值的方式来解决吗?
    这样的话DataBindings属性还有什么用呢?
    如果都要赋值的话, 要是有几十个字段要维护, 岂不是代码量很大?
      

  3.   

    on the client side, my method is probably the only way, unless you want to click on the datagrid, do a postback, bind the data to the textbox on the server side, which is so inefficient
      

  4.   

    up
    I do agree with Saucer.
      

  5.   

    即使通过服务端代码也很难绑定呀, 用下面的代码绑定不到, 但是静态绑定就可以绑定:
    TextBox1.Attributes["Text"] = "<%# DataBinder.Eval(dataSet11, \"Tables[Employees].DefaultView.[0].FirstName\") %>)";
    TextBox1.DataBind();