4 messaggi dal 17 marzo 2002
Ciao a tutti
in una pagina web aspx (vb.net) ho inserito una gridview all'interno di una gridview, tutto ok funziona grazie a un javascript che pensa a fare il mostra/hide
Problemino, quando seleziono un riga mi si apre la sottogriglia ma la riga non viene evidenziata...
Avrei bisogno di leggere dei valori presenti nella prima riga ma non ci riesco appunto perchè non ho un select value..

ho l'evento SelectedIndexChanged ma non riesco ad accedere alla riga come faccio di solito

Dim row As GridViewRow
row = GridView1.SelectedRow
Session("CodLavorazione") = row.Cells(1).Text



"
Protected Sub GridView1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles GridView1.SelectedIndexChanged


End Sub
"

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="VistaPresse.aspx.vb" Inherits="Molds.VistaPresse" %>

<!DOCTYPE html>



<script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
<script type = "text/javascript" >
$("[src*=plus]").live("click", function () {
$(this).closest("tr").after("<tr><td></td><td colspan = '999'>" + $(this).next().html() + "</td></tr>")
$(this).attr("src", "images/minus.png");
});
$("[src*=minus]").live("click", function () {
$(this).attr("src", "images/plus.png");
$(this).closest("tr").next().remove();
});
</script>


<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">

.auto-style5 {
width: 67px;
height: 67px;
}
</style>
</head>

<body>
<form id="form1" runat="server">
<div>
<a href="index.aspx"><img alt="" class="auto-style5" src="images/png-home-icon-15.jpg" /></a>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Gestione Lavorazioni</div>


<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="CodPressa" OnRowDataBound="OnRowDataBound" CellPadding="4" ForeColor="#333333" GridLines="None" AllowPaging="True" AllowSorting="True">
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<Columns>

<asp:CommandField ShowSelectButton="True" />

<asp:TemplateField>
<ItemTemplate>
<img alt="" style="cursor: pointer" src="images/plus.png" />
<asp:Panel ID="pnlOrders" runat="server" Style="display: none">

<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" BackColor="LightGoldenrodYellow" BorderColor="Tan" BorderWidth="1px" CellPadding="2" ForeColor="Black" GridLines="None">
<AlternatingRowStyle BackColor="PaleGoldenrod" />
<Columns>

<asp:BoundField DataField="Priorità" HeaderText="Priorità" SortExpression="Priorità" />
<asp:BoundField DataField="CodLavorazione" HeaderText="CodLavorazione" SortExpression="CodLavorazione" />
<asp:BoundField DataField="Descrizione" HeaderText="Descrizione" SortExpression="Descrizione" />
<asp:BoundField DataField="Status" HeaderText="Status" SortExpression="Status" />
<asp:BoundField DataField="CodStampo" HeaderText="CodStampo" SortExpression="CodStampo" />
<asp:BoundField DataField="DescrizioneStampo" HeaderText="DescrizioneStampo" SortExpression="DescrizioneStampo" />
<asp:BoundField DataField="StatusStampo" HeaderText="StatusStampo" SortExpression="StatusStampo" />
<asp:BoundField DataField="CodSet" HeaderText="CodSet" SortExpression="CodSet" />
<asp:BoundField DataField="DesSet" HeaderText="DesSet" SortExpression="DesSet" />
<asp:BoundField DataField="StatusSet" HeaderText="StatusSet" SortExpression="StatusSet" />
<asp:BoundField DataField="DataCambioStatus" HeaderText="DataCambioStatus" SortExpression="DataCambioStatus" />
<asp:BoundField DataField="DataIni" HeaderText="DataIni" SortExpression="DataIni" />
<asp:BoundField DataField="DataFine" HeaderText="DataFine" SortExpression="DataFine" />
<asp:BoundField DataField="OreLavorate" HeaderText="OreLavorate" SortExpression="OreLavorate" />
<asp:BoundField DataField="Operatore" HeaderText="Operatore" SortExpression="Operatore" />
<asp:BoundField DataField="qta" HeaderText="qta" SortExpression="qta" />
<asp:BoundField DataField="Avvisa" HeaderText="Avvisa" SortExpression="Avvisa" />
<asp:BoundField DataField="DataStartPrev" HeaderText="DataStartPrev" SortExpression="DataStartPrev" />
<asp:BoundField DataField="DataFinePrev" HeaderText="DataFinePrev" SortExpression="DataFinePrev" />
<asp:BoundField DataField="OrePreviste" HeaderText="OrePreviste" SortExpression="OrePreviste" />
<asp:BoundField DataField="OreResidue" HeaderText="OreResidue" SortExpression="OreResidue" />
</Columns>
<FooterStyle BackColor="Tan" />
<HeaderStyle BackColor="Tan" Font-Bold="True" />
<PagerStyle BackColor="PaleGoldenrod" ForeColor="DarkSlateBlue" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="DarkSlateBlue" ForeColor="GhostWhite" />
<SortedAscendingCellStyle BackColor="#FAFAE7" />
<SortedAscendingHeaderStyle BackColor="#DAC09E" />
<SortedDescendingCellStyle BackColor="#E1DB9C" />
<SortedDescendingHeaderStyle BackColor="#C2A47B" />
</asp:GridView>



</asp:Panel>
</ItemTemplate>
</asp:TemplateField>

<asp:BoundField DataField="CodPressa" HeaderText="CodPressa" ReadOnly="True" SortExpression="CodPressa" />
<asp:BoundField DataField="Descrizione" HeaderText="Descrizione" SortExpression="Descrizione" />
<asp:BoundField DataField="Status" HeaderText="Status" SortExpression="Status" />
<asp:BoundField DataField="Posizione" HeaderText="Posizione" SortExpression="Posizione" />
<asp:BoundField DataField="OrePreviste" HeaderText="OrePreviste" SortExpression="OrePreviste" />
<asp:BoundField DataField="OreResidue" HeaderText="OreResidue" SortExpression="OreResidue" />
<asp:BoundField DataField="Note" HeaderText="Note" SortExpression="Note" />
<asp:BoundField DataField="DataCambioStatus" HeaderText="DataCambioStatus" SortExpression="DataCambioStatus" />
<asp:BoundField DataField="Avvisal" HeaderText="Avvisal" SortExpression="Avvisal" />
<asp:BoundField DataField="GruppoAlert" HeaderText="GruppoAlert" SortExpression="GruppoAlert" />
</Columns>
<EditRowStyle BackColor="#999999" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#E9E7E2" />
<SortedAscendingHeaderStyle BackColor="#506C8C" />
<SortedDescendingCellStyle BackColor="#FFFDF8" />
<SortedDescendingHeaderStyle BackColor="#6F8DAE" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:MoldsConnectionString2 %>" SelectCommand="SELECT * FROM [Presse] WHERE ([Status] &lt;&gt; @Status)">
<SelectParameters>
<asp:Parameter DefaultValue="Magazzino" Name="Status" Type="String" />
</SelectParameters>
</asp:SqlDataSource>





</form>
</body>
</html>





Imports System.Data.SqlClient
Imports System.Drawing
Imports System.Net.Mail

Public Class VistaPresse
Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
GridView1.DataSource = GetData("select * from Presse")
GridView1.DataBind()
Else
GridView1.DataSource = GetData("select * from Presse where CodPressa='" & Session("CodicePressa") & "'")
GridView1.DataBind()

End If
End Sub

Private Shared Function GetData(query As String) As DataTable
Dim strConnString As String = ConfigurationManager.ConnectionStrings("MoldsConnectionString2").ConnectionString
Using con As New SqlConnection(strConnString)
Using cmd As New SqlCommand()
cmd.CommandText = query
Using sda As New SqlDataAdapter()
cmd.Connection = con
sda.SelectCommand = cmd
Using ds As New DataSet()
Dim dt As New DataTable()
sda.Fill(dt)
Return dt
End Using
End Using
End Using
End Using
End Function




Protected Sub OnRowDataBound(sender As Object, e As GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.DataRow Then
Dim CodicePressa As String = Trim(GridView1.DataKeys(e.Row.RowIndex).Value.ToString())
Dim subgrid As GridView = TryCast(e.Row.FindControl("GridView2"), GridView)
subgrid.DataSource = GetData(String.Format("select * from Lavorazioni_View where CodPressa= '" & CodicePressa & "'", CodicePressa))
subgrid.DataBind()

For y As Integer = 0 To subgrid.Rows.Count - 1
For x As Integer = 0 To subgrid.Columns.Count - 1
Select Case Trim(subgrid.Rows(y).Cells(x).Text)
Case "Magazzino"
subgrid.Rows(y).Cells(x).BackColor = Color.LightGray
Case "Produzione"
' If Trim(subgrid.Rows(y).Cells(4).Text) = "Produzione" Then
subgrid.Rows(y).Cells(x).BackColor = Color.LightGreen

' End If
Case "Guasto"
subgrid.Rows(y).Cells(x).BackColor = Color.Red
Case "Fermo"
subgrid.Rows(y).Cells(x).BackColor = Color.Yellow
End Select
Next
Next


End If
End Sub



Private Sub GridView1_DataBound(sender As Object, e As EventArgs) Handles GridView1.DataBound
For y As Integer = 0 To GridView1.Rows.Count - 1

For x As Integer = 0 To GridView1.Columns.Count - 1
Select Case Trim(GridView1.Rows(y).Cells(x).Text)
Case "Magazzino"
GridView1.Rows(y).Cells(x).BackColor = Color.LightGray
Case "Produzione"
If Trim(GridView1.Rows(y).Cells(4).Text) = "Produzione" Then
GridView1.Rows(y).Cells(x).BackColor = Color.LightGreen
Else
GridView1.Rows(y).Cells(x).Font.Strikeout = True
End If
Case "Guasto"
GridView1.Rows(y).Cells(x).BackColor = Color.Red
Case "Fermo"
GridView1.Rows(y).Cells(x).BackColor = Color.Yellow
End Select

Next

Next
End Sub

Protected Sub GridView1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles GridView1.SelectedIndexChanged


End Sub
End Class
Modificato da dibia il 19 novembre 2019 08:17 -

Torna al forum | Feed RSS

ASPItalia.com non è responsabile per il contenuto dei messaggi presenti su questo servizio, non avendo nessun controllo sui messaggi postati nei propri forum, che rappresentano l'espressione del pensiero degli autori.