Torna al Thread

<asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDS_tabella" EnableSortingAndPagingCallbacks="true" EnableViewState="true" ShowFooter="true" AutoGenerateColumns="true" AllowSorting="True" /> Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Me.IsPostBack() Then Try Dim sSQL As String sSQL = ViewState("MySQL") SqlDS_tabella.SelectCommand = sSQL Catch ex As Exception ClientScript.RegisterStartupScript(Me.[GetType](), "myalert", "alert('" & ex.Message & "');", True) End Try End If End Sub Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click Try Dim Where As String = String.Empty Dim sSQL As String = String.Empty Select Case op_anno.SelectedValue.ToString Where = " WHERE anno " & op_anno.SelectedValue.ToString & " " & ddlanno1.SelectedValue.ToString & " AND " & " " & ddlanno2.SelectedValue.ToString End Select 'stringa select e group by per View Dim SelectGroupby As String = String.Empty SelectGroupby = Replace(campi.SelectedValueList.ToString, "'", "") 'se non ci sono campi nella select e group by esco ! If String.IsNullOrEmpty(SelectGroupby) Then Dim myInfo As String = "nessun campo da visualizzare selezionato!" ClientScript.RegisterStartupScript(Me.[GetType](), "myalert", "alert('" & myInfo & "');", True) Exit Sub End If sSQL = " SELECT " & SelectGroupby & ", SUM(importo) as ordinato... " & _ " FROM (SELECT anno, ..., ...," & _ " ..." & _ " FROM tab_ordinato " & Where & ") Tab " & _ " GROUP BY " & SelectGroupby ' Response.Write(sSQL.ToString) ' per aggiungere campi inserire AUTOGENERATECOLUMNS="FALSE" ' For Each li As ListItem In campi.Items ' If li.Selected = True Then ' GridView1.Columns.Add(New BoundField() With {.DataField = li.ToString, .HeaderText = li.ToString}) ' End If ' Next SqlDS_tabella.SelectCommand = sSQL ViewState("MySQL") = sSQL Catch ex As Exception lbl_err_sql.Text = ex.Message End Try End Sub
Copyright © dotNetHell.it 2002-2025
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5