ayuda null en datagridview rowcommand
Publicado por sebastian (1 intervención) el 27/07/2017 02:04:11
Hola, tengo un problema utilizando el row command en una gridview.
al presionar un imgButton, rescato el ID que esta en la misma fila que el imgButton que presione, para luego comparar con datos en la BD, el problema es que al presionar el imgButton, me arroja el siguiente error.
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
[NullReferenceException: Object reference not set to an instance of an object.]
IngemarsPlataformaV1.asasa.GridView1_RowCommand(Object sender, GridViewCommandEventArgs e) +659
System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +172
System.Web.UI.WebControls.GridViewRow.OnBubbleEvent(Object source, EventArgs e) +163
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +83
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3803
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18408
Adjunto Codigo html
Adjunto Codigo VB
me di cuenta que el problema solo me aparece cuando esta el código en el servidor, desde mi PC en visual studio funciona perfectamente :SSS, la verdad ya no se que más puedo hacer.
de ante mano gracias
al presionar un imgButton, rescato el ID que esta en la misma fila que el imgButton que presione, para luego comparar con datos en la BD, el problema es que al presionar el imgButton, me arroja el siguiente error.
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
[NullReferenceException: Object reference not set to an instance of an object.]
IngemarsPlataformaV1.asasa.GridView1_RowCommand(Object sender, GridViewCommandEventArgs e) +659
System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +172
System.Web.UI.WebControls.GridViewRow.OnBubbleEvent(Object source, EventArgs e) +163
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +83
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3803
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18408
Adjunto Codigo html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataKeyNames="Ruta" OnRowCommand="GridView1_RowCommand"
OnSelectedIndexChanged="GridView1_SelectedIndexChanged" CssClass="mGrid" PagerStyle-CssClass="pgr"
GridLines="None" AlternatingRowStyle-CssClass="alt" PageSize="7"
Font-Size="Medium">
<AlternatingRowStyle CssClass="alt"></AlternatingRowStyle>
<Columns >
<asp:BoundField DataField="ID" HeaderText="ID" HeaderStyle-Font-Size="Medium" />
<asp:BoundField DataField="nombre" HeaderText="Nombre" HeaderStyle-Font-Size="Medium" />
<asp:BoundField DataField="numeroInforme" HeaderText="N° Informe" HeaderStyle-Font-Size="Medium" />
<asp:BoundField DataField="empresa" HeaderText="Empresa" HeaderStyle-Font-Size="Medium" />
<asp:BoundField DataField="obra" HeaderText="Obra" HeaderStyle-Font-Size="Medium" />
<asp:TemplateField HeaderText="Vista Previa" HeaderStyle-Font-Size="Medium">
<ItemTemplate>
<asp:ImageButton ID="imagen" runat="server" CommandName="Select"
ImageUrl="../../Images/Places-folder-downloads-icon.png" Style="width: 40px; height: 40px;"/>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Firmar / No Firmar" HeaderStyle-Font-Size="Medium">
<ItemTemplate>
<asp:ImageButton ID="imagenAprobar" runat="server" CommandName="aceptarBT" CommandArgument='<%#Eval("ID").ToString %>'
ImageUrl="../../Images/aproba32.jpg" Style="width: 40px; height: 40px;" />
<asp:ImageButton ID="imagenRechazar" runat="server" CommandName="rechazarBT" CommandArgument='<%#Eval("ID").ToString %>'
ImageUrl="../../Images/nofirma.jpg" Style="width: 40px; height: 40px;" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<HeaderStyle Font-Size="Large" Font-Underline="False" />
<PagerStyle CssClass="pgr"></PagerStyle>
<RowStyle HorizontalAlign="Center" VerticalAlign="Middle" />
</asp:GridView>
Adjunto Codigo VB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
Dim cl As New ControladorLogica
Dim listaTabla As New List(Of Tabla)()
Protected Sub GridView1_RowCommand(sender As Object, e As GridViewCommandEventArgs) Handles GridView1.RowCommand
If e.CommandName = "aceptarBT" Then
Dim contenidoID As String = e.CommandArgument.ToString()
Dim code As Integer = cl.obtenerDigitoInforme(contenidoID)
If (cl.isMoroso(code)) Then
"hacer algo"
else
"hacer algo"
End If
end Sub
me di cuenta que el problema solo me aparece cuando esta el código en el servidor, desde mi PC en visual studio funciona perfectamente :SSS, la verdad ya no se que más puedo hacer.
de ante mano gracias
Valora esta pregunta


0