P
PatLaf
Hello all
I have nested a datagrid within a datagrid to display detail records. It kinda works but what I need to do is draw out a check list box I think as this is a dataentry application and I may need to trap what is selected and I need to do that by row. As I think when the user presses the submit button I will need to iterate through the grid, determine if the user selected details and if they did collect that information. Does anyone know how to do this? I am copying the code I have so far that seems to work except when the user clicks on the details button I get a datagrid displayed that shows two columns, row error and Has errors. With the latter column all set to false.......please forgive any ignorance as I am new to asp.net and vb.ne
vb cod
Private Sub dgDefects_ItemCommand(ByVal source As System.Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dgDefects.ItemComman
Dim iValue As Intege
iValue = Integer.Parse(CType(e.Item.Controls(5), TableCell).Text
'handle defects on dgDefects Gri
If e.CommandName = "Increase" The
CType(e.Item.Controls(5), TableCell).Text = (iValue + 1).ToString(
ElseIf e.CommandName = "Decrease" The
If Not CType(e.Item.Controls(5), TableCell).Text <= "0" The
CType(e.Item.Controls(5), TableCell).Text = (iValue - 1).ToString(
End I
End I
If CType(e.CommandSource, Button).Text = "Show Details" The
dgDefects.Columns(7).Visible = Tru
Dim dgi As DataGridItem = CType(e.Item, DataGridItem
Dim c As Contro
For Each c In dgi.Cells(7).Control
c.Visible = Tru
Nex
CType(e.CommandSource, Button).Text = "Hide Details
ElseIf CType(e.CommandSource, Button).Text = "Hide Details" The
dgDefects.Columns(7).Visible = Fals
Dim dgi As DataGridItem = CType(e.Item, DataGridItem
Dim c As Contro
For Each c In dgi.Cells(7).Control
c.Visible = Fals
Nex
CType(e.CommandSource, Button).Text = "Show Details
End I
End Sub 'dgDefects_ItemCommand
Private Sub dgDefects_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles dgDefects.ItemDataBoun
Dim dgi As DataGridItem = e.Ite
If dgi.ItemType = ListItemType.Item Or dgi.ItemType = ListItemType.AlternatingItem The
Dim c As Contro
For Each c In dgi.Cells(7).Control
If TypeOf (c) Is System.Web.UI.WebControls.DataGrid The
Dim id As Int32 = Int32.Parse(dgi.Cells(0).Text
Dim dg As DataGrid = CType(c, DataGrid
Dim dr As DataRow(
dr = m_dsDefects.Tables("Defect_Details").Select("Defect_ID=" & id
If dr.Length > 0 The
dg.DataSource = d
dg.DataBind(
Els
Dim dt As DataTable = New DataTabl
Dim dr2 As DataRo
Dim dtCol As DataColumn = New DataColum
With dtCo
.ColumnName = "Detail Disposition
.DataType = System.Type.GetType("System.String"
.DefaultValue = "NO DETAILS
End Wit
dt.Columns.Add(dtCol
' Add one row. Since it has default values, no need to set values
dr2 = dt.NewRo
dt.Rows.Add(dr2
dg.DataSource = d
dg.DataBind(
End I
End I
Nex
End I
End Su
htm
<form id="Form1" method="post" runat="server"><asp:label id="lblError" style="Z-INDEX: 101; LEFT: 24px; POSITION: absolute; TOP: 528px" runat="server
Visible="False" Width="256px" Height="64px">Label</asp:label><asp:Button id="btnSaveAuditInfo" style="Z-INDEX: 125; LEFT: 632px; POSITION: absolute; TOP: 488px
runat="server" Width="98px" Text="Complete Audit"></asp:Button><asp:Label id="lblAuditorId" style="Z-INDEX: 124; LEFT: 776px; POSITION: absolute; TOP: 24px"
runat="server" Visible="False" Enabled="False"></asp:Label><asp:textbox id="txtLotNum" style="Z-INDEX: 123; LEFT: 776px; POSITION: absolute; TOP: 136px"
runat="server" Width="184px" ForeColor="Black" BackColor="#E0E0E0"></asp:textbox><asp:textbox id="txtAuditType" style="Z-INDEX: 122; LEFT: 776px; POSITION: absolute; TOP: 80px"
runat="server" Width="184px" ForeColor="Black" BackColor="#E0E0E0"></asp:textbox><asp:textbox id="txtAuditor" style="Z-INDEX: 121; LEFT: 776px; POSITION: absolute; TOP: 192px"
runat="server" Width="184px" ForeColor="Black" BackColor="#E0E0E0"></asp:textbox><asp:label id="lblLotNumber" style="Z-INDEX: 120; LEFT: 776px; POSITION: absolute; TOP: 112px"
runat="server" Height="24px" Width="80px" ForeColor="White">Lot Number</asp:label><asp:label id="lblSampleSize" style="Z-INDEX: 119; LEFT: 776px; POSITION: absolute; TOP: 368px"
runat="server" Height="16px" Width="96px" ForeColor="White">Sample Size</asp:label><asp:textbox id="txtSampleSize" style="Z-INDEX: 116; LEFT: 776px; POSITION: absolute; TOP: 392px"
runat="server" Width="184px" ForeColor="Black" BackColor="#E0E0E0"></asp:textbox><asp:label id="lblMisPackAql" style="Z-INDEX: 118; LEFT: 776px; POSITION: absolute; TOP: 464px"
runat="server" Height="16px" Width="96px" ForeColor="White">MisPack AQL</asp:label><asp:textbox id="txtMisPackAQL" style="Z-INDEX: 117; LEFT: 776px; POSITION: absolute; TOP: 488px"
runat="server" Width="184px" ForeColor="Black" BackColor="#E0E0E0"></asp:textbox><asp:textbox id="txtCosAql" style="Z-INDEX: 115; LEFT: 776px; POSITION: absolute; TOP: 440px"
runat="server" Width="184px" ForeColor="Black" BackColor="#E0E0E0"></asp:textbox><asp:label id="lblAuditSize" style="Z-INDEX: 114; LEFT: 776px; POSITION: absolute; TOP: 56px"
runat="server" Height="16px" Width="72px" ForeColor="White">Audit Type</asp:label><asp:label id="lblMfg" style="Z-INDEX: 113; LEFT: 776px; POSITION: absolute; TOP: 320px" runat="server"
Height="16px" Width="40px" ForeColor="White">Supplier</asp:label><asp:textbox id="txtMfg" style="Z-INDEX: 110; LEFT: 776px; POSITION: absolute; TOP: 344px" runat="server"
Width="184px" ForeColor="Black" BackColor="#E0E0E0"></asp:textbox><asp:label id="lblPrdType" style="Z-INDEX: 112; LEFT: 776px; POSITION: absolute; TOP: 272px"
runat="server" Height="16px" Width="96px" ForeColor="White">Product Type</asp:label><asp:textbox id="txtPrdType" style="Z-INDEX: 109; LEFT: 776px; POSITION: absolute; TOP: 296px"
runat="server" Width="184px" ForeColor="Black" BackColor="#E0E0E0"></asp:textbox><asp:label id="lblLotSize" style="Z-INDEX: 111; LEFT: 776px; POSITION: absolute; TOP: 224px"
runat="server" Height="16px" Width="64px" ForeColor="White">Lot Size</asp:label><asp:textbox id="txtLotSize" style="Z-INDEX: 108; LEFT: 776px; POSITION: absolute; TOP: 248px"
runat="server" Width="184px" ForeColor="Black" BackColor="#E0E0E0"></asp:textbox><asp:label id="lblCosmeticAql" style="Z-INDEX: 107; LEFT: 776px; POSITION: absolute; TOP: 416px"
runat="server" Height="16px" Width="96px" ForeColor="White">Cosmetic AQL</asp:label><asp:label id="lblAuditors" style="Z-INDEX: 106; LEFT: 776px; POSITION: absolute; TOP: 168px"
runat="server" Height="24px" Width="56px" ForeColor="White">Auditor</asp:label><asp:label id="lblCosDefects" style="Z-INDEX: 104; LEFT: 16px; POSITION: absolute; TOP: 80px"
runat="server" Width="152px" Height="16px" Font-Size="Larger" ForeColor="White">Cosmetic Defects</asp:label><asp:label id="lblAudit" style="Z-INDEX: 103; LEFT: 392px; POSITION: absolute; TOP: 80px" runat="server"
Width="152px" Height="16px" Font-Size="Larger" ForeColor="White">TOI Auditors Center</asp:label><asp:image id="Image1" style="Z-INDEX: 102; LEFT: 336px; POSITION: absolute; TOP: 8px" runat="server"
Width="264px" Height="72px" ImageUrl="file:///C:\Inetpub\wwwroot\TOIAUDIT\Images\transitions-logo.gif"></asp:image>
<DIV style="OVERFLOW-Y: scroll; Z-INDEX: 105; LEFT: 16px; WIDTH: 525px; POSITION: absolute; TOP: 104px; HEIGHT: 360px"><asp:datagrid id="dgDefects" runat="server" Width="400px" Height="200px" CellPadding="3" BackColor="White"
BorderWidth="2px" BorderStyle="Ridge" BorderColor="White" AutoGenerateColumns="False" CellSpacing="1" GridLines="None"><SelectedItemStyle Font-Bold="True" ForeColor="White" BackColor="#9471DE"></SelectedItemStyle><ItemStyle ForeColor="Black" BackColor="#DEDFDE"></ItemStyle><HeaderStyle Font-Bold="True" ForeColor="#E7E7FF" BackColor="#4A3C8C"></HeaderStyle><FooterStyle ForeColor="Black" BackColor="#C6C3C6"></FooterStyle><Columns><asp:BoundColumn Visible="False" DataField="Defect_ID" HeaderText="ID"></asp:BoundColumn><asp:ButtonColumn Text="Increase" ButtonType="PushButton" HeaderText="Add One" CommandName="Increase"></asp:ButtonColumn><asp:ButtonColumn Text="Decrease" ButtonType="PushButton" HeaderText="Subtract One" CommandName="Decrease"></asp:ButtonColumn><asp:BoundColumn DataField="Defect" HeaderText="Defect Description"></asp:BoundColumn><asp:BoundColumn DataField="Defect_Acronym" HeaderText="Defect Acronym"></asp:BoundColumn><asp:BoundColumn DataField="Defect_NumDefects" HeaderText="Number Found"></asp:BoundColumn><asp:ButtonColumn Text="Show Details" ButtonType="PushButton" HeaderText="Details">
I have nested a datagrid within a datagrid to display detail records. It kinda works but what I need to do is draw out a check list box I think as this is a dataentry application and I may need to trap what is selected and I need to do that by row. As I think when the user presses the submit button I will need to iterate through the grid, determine if the user selected details and if they did collect that information. Does anyone know how to do this? I am copying the code I have so far that seems to work except when the user clicks on the details button I get a datagrid displayed that shows two columns, row error and Has errors. With the latter column all set to false.......please forgive any ignorance as I am new to asp.net and vb.ne
vb cod
Private Sub dgDefects_ItemCommand(ByVal source As System.Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dgDefects.ItemComman
Dim iValue As Intege
iValue = Integer.Parse(CType(e.Item.Controls(5), TableCell).Text
'handle defects on dgDefects Gri
If e.CommandName = "Increase" The
CType(e.Item.Controls(5), TableCell).Text = (iValue + 1).ToString(
ElseIf e.CommandName = "Decrease" The
If Not CType(e.Item.Controls(5), TableCell).Text <= "0" The
CType(e.Item.Controls(5), TableCell).Text = (iValue - 1).ToString(
End I
End I
If CType(e.CommandSource, Button).Text = "Show Details" The
dgDefects.Columns(7).Visible = Tru
Dim dgi As DataGridItem = CType(e.Item, DataGridItem
Dim c As Contro
For Each c In dgi.Cells(7).Control
c.Visible = Tru
Nex
CType(e.CommandSource, Button).Text = "Hide Details
ElseIf CType(e.CommandSource, Button).Text = "Hide Details" The
dgDefects.Columns(7).Visible = Fals
Dim dgi As DataGridItem = CType(e.Item, DataGridItem
Dim c As Contro
For Each c In dgi.Cells(7).Control
c.Visible = Fals
Nex
CType(e.CommandSource, Button).Text = "Show Details
End I
End Sub 'dgDefects_ItemCommand
Private Sub dgDefects_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles dgDefects.ItemDataBoun
Dim dgi As DataGridItem = e.Ite
If dgi.ItemType = ListItemType.Item Or dgi.ItemType = ListItemType.AlternatingItem The
Dim c As Contro
For Each c In dgi.Cells(7).Control
If TypeOf (c) Is System.Web.UI.WebControls.DataGrid The
Dim id As Int32 = Int32.Parse(dgi.Cells(0).Text
Dim dg As DataGrid = CType(c, DataGrid
Dim dr As DataRow(
dr = m_dsDefects.Tables("Defect_Details").Select("Defect_ID=" & id
If dr.Length > 0 The
dg.DataSource = d
dg.DataBind(
Els
Dim dt As DataTable = New DataTabl
Dim dr2 As DataRo
Dim dtCol As DataColumn = New DataColum
With dtCo
.ColumnName = "Detail Disposition
.DataType = System.Type.GetType("System.String"
.DefaultValue = "NO DETAILS
End Wit
dt.Columns.Add(dtCol
' Add one row. Since it has default values, no need to set values
dr2 = dt.NewRo
dt.Rows.Add(dr2
dg.DataSource = d
dg.DataBind(
End I
End I
Nex
End I
End Su
htm
<form id="Form1" method="post" runat="server"><asp:label id="lblError" style="Z-INDEX: 101; LEFT: 24px; POSITION: absolute; TOP: 528px" runat="server
Visible="False" Width="256px" Height="64px">Label</asp:label><asp:Button id="btnSaveAuditInfo" style="Z-INDEX: 125; LEFT: 632px; POSITION: absolute; TOP: 488px
runat="server" Width="98px" Text="Complete Audit"></asp:Button><asp:Label id="lblAuditorId" style="Z-INDEX: 124; LEFT: 776px; POSITION: absolute; TOP: 24px"
runat="server" Visible="False" Enabled="False"></asp:Label><asp:textbox id="txtLotNum" style="Z-INDEX: 123; LEFT: 776px; POSITION: absolute; TOP: 136px"
runat="server" Width="184px" ForeColor="Black" BackColor="#E0E0E0"></asp:textbox><asp:textbox id="txtAuditType" style="Z-INDEX: 122; LEFT: 776px; POSITION: absolute; TOP: 80px"
runat="server" Width="184px" ForeColor="Black" BackColor="#E0E0E0"></asp:textbox><asp:textbox id="txtAuditor" style="Z-INDEX: 121; LEFT: 776px; POSITION: absolute; TOP: 192px"
runat="server" Width="184px" ForeColor="Black" BackColor="#E0E0E0"></asp:textbox><asp:label id="lblLotNumber" style="Z-INDEX: 120; LEFT: 776px; POSITION: absolute; TOP: 112px"
runat="server" Height="24px" Width="80px" ForeColor="White">Lot Number</asp:label><asp:label id="lblSampleSize" style="Z-INDEX: 119; LEFT: 776px; POSITION: absolute; TOP: 368px"
runat="server" Height="16px" Width="96px" ForeColor="White">Sample Size</asp:label><asp:textbox id="txtSampleSize" style="Z-INDEX: 116; LEFT: 776px; POSITION: absolute; TOP: 392px"
runat="server" Width="184px" ForeColor="Black" BackColor="#E0E0E0"></asp:textbox><asp:label id="lblMisPackAql" style="Z-INDEX: 118; LEFT: 776px; POSITION: absolute; TOP: 464px"
runat="server" Height="16px" Width="96px" ForeColor="White">MisPack AQL</asp:label><asp:textbox id="txtMisPackAQL" style="Z-INDEX: 117; LEFT: 776px; POSITION: absolute; TOP: 488px"
runat="server" Width="184px" ForeColor="Black" BackColor="#E0E0E0"></asp:textbox><asp:textbox id="txtCosAql" style="Z-INDEX: 115; LEFT: 776px; POSITION: absolute; TOP: 440px"
runat="server" Width="184px" ForeColor="Black" BackColor="#E0E0E0"></asp:textbox><asp:label id="lblAuditSize" style="Z-INDEX: 114; LEFT: 776px; POSITION: absolute; TOP: 56px"
runat="server" Height="16px" Width="72px" ForeColor="White">Audit Type</asp:label><asp:label id="lblMfg" style="Z-INDEX: 113; LEFT: 776px; POSITION: absolute; TOP: 320px" runat="server"
Height="16px" Width="40px" ForeColor="White">Supplier</asp:label><asp:textbox id="txtMfg" style="Z-INDEX: 110; LEFT: 776px; POSITION: absolute; TOP: 344px" runat="server"
Width="184px" ForeColor="Black" BackColor="#E0E0E0"></asp:textbox><asp:label id="lblPrdType" style="Z-INDEX: 112; LEFT: 776px; POSITION: absolute; TOP: 272px"
runat="server" Height="16px" Width="96px" ForeColor="White">Product Type</asp:label><asp:textbox id="txtPrdType" style="Z-INDEX: 109; LEFT: 776px; POSITION: absolute; TOP: 296px"
runat="server" Width="184px" ForeColor="Black" BackColor="#E0E0E0"></asp:textbox><asp:label id="lblLotSize" style="Z-INDEX: 111; LEFT: 776px; POSITION: absolute; TOP: 224px"
runat="server" Height="16px" Width="64px" ForeColor="White">Lot Size</asp:label><asp:textbox id="txtLotSize" style="Z-INDEX: 108; LEFT: 776px; POSITION: absolute; TOP: 248px"
runat="server" Width="184px" ForeColor="Black" BackColor="#E0E0E0"></asp:textbox><asp:label id="lblCosmeticAql" style="Z-INDEX: 107; LEFT: 776px; POSITION: absolute; TOP: 416px"
runat="server" Height="16px" Width="96px" ForeColor="White">Cosmetic AQL</asp:label><asp:label id="lblAuditors" style="Z-INDEX: 106; LEFT: 776px; POSITION: absolute; TOP: 168px"
runat="server" Height="24px" Width="56px" ForeColor="White">Auditor</asp:label><asp:label id="lblCosDefects" style="Z-INDEX: 104; LEFT: 16px; POSITION: absolute; TOP: 80px"
runat="server" Width="152px" Height="16px" Font-Size="Larger" ForeColor="White">Cosmetic Defects</asp:label><asp:label id="lblAudit" style="Z-INDEX: 103; LEFT: 392px; POSITION: absolute; TOP: 80px" runat="server"
Width="152px" Height="16px" Font-Size="Larger" ForeColor="White">TOI Auditors Center</asp:label><asp:image id="Image1" style="Z-INDEX: 102; LEFT: 336px; POSITION: absolute; TOP: 8px" runat="server"
Width="264px" Height="72px" ImageUrl="file:///C:\Inetpub\wwwroot\TOIAUDIT\Images\transitions-logo.gif"></asp:image>
<DIV style="OVERFLOW-Y: scroll; Z-INDEX: 105; LEFT: 16px; WIDTH: 525px; POSITION: absolute; TOP: 104px; HEIGHT: 360px"><asp:datagrid id="dgDefects" runat="server" Width="400px" Height="200px" CellPadding="3" BackColor="White"
BorderWidth="2px" BorderStyle="Ridge" BorderColor="White" AutoGenerateColumns="False" CellSpacing="1" GridLines="None"><SelectedItemStyle Font-Bold="True" ForeColor="White" BackColor="#9471DE"></SelectedItemStyle><ItemStyle ForeColor="Black" BackColor="#DEDFDE"></ItemStyle><HeaderStyle Font-Bold="True" ForeColor="#E7E7FF" BackColor="#4A3C8C"></HeaderStyle><FooterStyle ForeColor="Black" BackColor="#C6C3C6"></FooterStyle><Columns><asp:BoundColumn Visible="False" DataField="Defect_ID" HeaderText="ID"></asp:BoundColumn><asp:ButtonColumn Text="Increase" ButtonType="PushButton" HeaderText="Add One" CommandName="Increase"></asp:ButtonColumn><asp:ButtonColumn Text="Decrease" ButtonType="PushButton" HeaderText="Subtract One" CommandName="Decrease"></asp:ButtonColumn><asp:BoundColumn DataField="Defect" HeaderText="Defect Description"></asp:BoundColumn><asp:BoundColumn DataField="Defect_Acronym" HeaderText="Defect Acronym"></asp:BoundColumn><asp:BoundColumn DataField="Defect_NumDefects" HeaderText="Number Found"></asp:BoundColumn><asp:ButtonColumn Text="Show Details" ButtonType="PushButton" HeaderText="Details">