日期:2009-09-05 浏览次数:20463 次
<form id="Form1" method="post" runat="server"> <ASP:DataGrid id="DataGrid1" runat="server" AutoGenerateColumns="False" DataKeyField="EmployeeID"> <Columns> <ASP:TemplateColumn> <ItemTemplate> <ASP:CheckBox runat="server" ID="EmployeeCheckBox" /> </ItemTemplate> </ASP:TemplateColumn> <ASP:TemplateColumn> <ItemTemplate> <%# DataBinder.Eval(Container.DataItem, "LastName") %>, <%# DataBinder.Eval(Container.DataItem, "FirstName") %> </ItemTemplate> </ASP:TemplateColumn> </Columns> </ASP:DataGrid> <hr> <ASP:Button id="Orders" runat="server" Text="View Orders"></ASP:Button> <hr> <ASP:DataGrid ID="DataGrid2" Runat="server" AutoGenerateColumns="True" /> </form> |
private void Page_Load(object sender, System.EventArgs e) { if(!Page.IsPostBack) { Database db = DatabaseFactory.CreateDatabase(); DBCommandWrapper dbCommandWrapper; using(dbCommandWrapper = db.GetSqlStringCommandWrapper(SELECT_EMPLOYEES)) { using (IDataReader dataReader = db.ExecuteReader(dbCommandWrapper)) { DataGrid1.DataSource = dataReader; DataGrid1.DataBind(); } } } } |
SELECT EmployeeID, FirstName, LastName FROM Employees WHERE EmployeeID IN (7, 4) |
SELECT count(*) AS Orders, E.FirstName, E.LastName FROM Orders O INNER JOIN Employees E ON O.EmployeeID = E.EmployeeID WHERE E.EmployeeID IN(SELECT Value FROM fn_Split(@employeeIDs, ',')) GROUP BY FirstName, LastName ORDER BY count(*) DESC |
private string GetCheckedEmployeeIDs() { String delimiter = String.Empty; StringBuilder employeeIDs = new StringBuilder(); for(int i = 0; i < DataGrid1.Items.Count; i++) { CheckBox checkbox; checkbox = DataGrid1.Items[i].FindControl("EmployeeCheckBox") as CheckBox; if(checkbox !=
免责声明: 本文仅代表作者个人观点,与爱易网无关。其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
|