我做了一個代碼來顯示使用AspxGridView的記錄。現在我想顯示Footer和Grouping的總和(Column_Name),count(Column_Name)。如何使用動態綁定在AspxGridView中執行頁腳摘要和組摘要?
這是我的代碼:
<dx:ASPxGridView ID="ASPxGridView1" runat="server" >
<SettingsPager PageSize="50">
</SettingsPager>
<Settings ShowFilterRow="True" ShowGroupPanel="True" ShowFooter="True" ShowGroupFooter="VisibleIfExpanded" />
<SettingsCommandButton>
<ShowAdaptiveDetailButton ButtonType="Image"></ShowAdaptiveDetailButton>
<HideAdaptiveDetailButton ButtonType="Image"></HideAdaptiveDetailButton>
</SettingsCommandButton>
<SettingsDataSecurity AllowDelete="False" AllowEdit="False" AllowInsert="False" />
<SettingsSearchPanel Visible="True" />
</dx:ASPxGridView>
C#代碼:
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
{
ASPxGridView1.Visible = true;
string cs = ConfigurationManager.ConnectionStrings["HQMatajerConnectionString"].ConnectionString;
whereQuery = getWhereQuery();
using (SqlConnection con = new SqlConnection(cs))
{
string querysss = "select "+txtSelectedColumn.Text+ @"
FROM [HQMatajer].[dbo].[Transaction] as transactions
RIGHT JOIN [HQMatajer].[dbo].[TransactionEntry] as transactionsEntry
ON transactions.TransactionNumber=transactionsEntry.TransactionNumber
INNER JOIN [HQMatajer].[dbo].[Item] as items
ON transactionsEntry.ItemID=items.ID
INNER JOIN [HQMatajer].[dbo].[Supplier] as suppliers
ON items.SupplierID=suppliers.ID
LEFT JOIN [HQMatajer].[dbo].[Department] as departments
ON departments.ID=items.DepartmentID
LEFT JOIN [HQMatajer].[dbo].[Category] as categories
ON categories.ID=items.CategoryID
where " + txtQuery.Text;
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandText = querysss;
con.Open();
SqlDataAdapter sda = new SqlDataAdapter(cmd);
sda.Fill(ds);
ASPxGridView1.AutoGenerateColumns = true;
ASPxGridView1.DataSource = ds;
ASPxGridView1.DataBind();
}
}
你可以注意到,我的SQL查詢語句。在那個用戶只決定他們想要顯示哪一列。如果他們在select語句中選擇Price column_name。它必須在頁腳中顯示總和(價格)以用於所有記錄和分組以及如果用戶進行分組
也許開始使用LINQ to Entities?和實體框架。 –