gridview的OnRowDataBound必须存在




    <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");


    }

你可能感兴趣的:(GridView)