ASP.NET - al agregar el boton <asp:CommandField ShowSelectButton="True" /> ya no carga la información ayuda

 
Vista:
sin imagen de perfil
Val: 2
Ha disminuido su posición en 7 puestos en ASP.NET (en relación al último mes)
Gráfica de ASP.NET

al agregar el boton <asp:CommandField ShowSelectButton="True" /> ya no carga la información ayuda

Publicado por JOSE ANTONIO DE JESUS (1 intervención) el 24/06/2020 20:24:28
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Grid1.aspx.vb" Inherits="WebApplication1.Grid1" %>
 
<!DOCTYPE html>
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
      <style type="text/css">
        body
        {
            font-family: Arial;
            font-size: 10pt;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
 
     <div style="width: 500px">
        <asp:GridView ID="gvCustomers" runat="server" AutoGenerateColumns="False">
            <Columns>
            <asp:CommandField ShowSelectButton="True" /> 'si agrego este boton ya no me carga la informacion y necesito porder seleccionar registgros ayudaa'
                <asp:BoundField DataField="CustomerID" HeaderText="Customer Id" />
                <asp:BoundField DataField="ContactName" HeaderText="Name" />
                <asp:BoundField DataField="City" HeaderText="City" />
                <asp:BoundField DataField="Country" HeaderText="Country" />
 
 
            </Columns>
        </asp:GridView>
    </div>
    </form>
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
    <script type="text/javascript" src="https://cdn.datatables.net/1.10.20/js/jquery.dataTables.min.js"></script>
    <link href="https://cdn.datatables.net/1.10.20/css/jquery.dataTables.css" rel="stylesheet"
        type="text/css" />
    <script type="text/javascript">
        $(function () {
            $.ajax({
                type: "POST",
                url: "Grid1.aspx/GetCustomers",
                data: '{}',
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: OnSuccess,
                failure: function (response) {
                    alert(response.d);
                },
                error: function (response) {
                    alert(response.d);
                }
            });
        });
        function OnSuccess(response) {
            $("[id*=gvCustomers]").DataTable(
 
            {
                bLengthChange: true,
                lengthMenu: [[5, 10, -1], [5, 10, "All"]],
                bFilter: true,
                bSort: true,
                    bPaginate: true,
                    select: {
                        style: 'single'
                    },
 
                data: response.d,
                    columns: [{ 'data': 'CustomerID' },
                          { 'data': 'ContactName' },
                          { 'data': 'City' },
                        { 'data': 'Country' }]
 
            });
        };
    </script>
 
 
</body>
</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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
Imports System.Data
Imports System.Data.SqlClient
Imports System.Configuration
Imports System.Web.Services
Imports Newtonsoft.Json
Imports System.Linq
Imports System.IO
 
Partial Class Grid1
    Inherits System.Web.UI.Page
 
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not Me.IsPostBack Then
            Dim dummy As DataTable = New DataTable()
            dummy.Columns.Add("CustomerID")
            dummy.Columns.Add("ContactName")
            dummy.Columns.Add("City")
            dummy.Columns.Add("Country")
            dummy.Rows.Add()
            gvCustomers.DataSource = dummy
            gvCustomers.DataBind()
 
            'Required for jQuery DataTables to work.
            gvCustomers.UseAccessibleHeader = True
            gvCustomers.HeaderRow.TableSection = TableRowSection.TableHeader
        End If
    End Sub
    <WebMethod>
    Public Shared Function GetCustomers() As List(Of Customer)
        Dim customers As List(Of Customer) = New List(Of Customer)()
        Dim constr As String = ConfigurationManager.ConnectionStrings("constr").ConnectionString
        Using con As SqlConnection = New SqlConnection(constr)
            Using cmd As SqlCommand = New SqlCommand("SELECT CustomerID, ContactName, City, Country FROM Customers", con)
                con.Open()
                Using sdr As SqlDataReader = cmd.ExecuteReader()
                    While sdr.Read()
                        customers.Add(New Customer With {
                            .CustomerID = sdr("CustomerID").ToString(),
                            .ContactName = sdr("ContactName").ToString(),
                            .City = sdr("City").ToString(),
                            .Country = sdr("Country").ToString()
                        })
                    End While
                End Using
                con.Close()
            End Using
        End Using
        Return customers
    End Function
    Public Class Customer
        Public Property CustomerID As String
        Public Property ContactName As String
        Public Property City As String
        Public Property Country As String
    End Class
End Class

no me carga la informacion si agrego el boton seleccionar ayuda
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder