gridview的OnRowDataBound必须存在 <Columns>




    <asp:sqldatasource id="CustomersSource"
      selectcommand="SELECT * from t_staff"
      connectionstring="<%$ ConnectionStrings:db_BSCConnectionString %>" 

      runat="server"/>


<asp:gridview id="CustomersGridView" 
  datasourceid="CustomersSource" 
  autogeneratecolumns="False"
  emptydatatext="No data available." 
  allowpaging="True"  OnRowDataBound="GridView1_RowDataBound"
  runat="server" DataKeyNames="chn">
    <Columns>
        <asp:BoundField DataField="chn" HeaderText="CustomerID" 
            InsertVisible="False" ReadOnly="True" SortExpression="chn" />
    </Columns>

</asp:gridview>


  protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        Response.Write("123");


    }

posted @ 2013-05-02 21:00  y0umer  阅读(145)  评论(0编辑  收藏  举报