Estoy provando una plicacion de lmanual de es.gotdotnet, y cuando la corro no me muestra el datagrid y no se que hacer
Gracias por la ayuda de antemano
Este es codijo que estoy usando
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Data" %>
<%@ Page language="VB" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="Rainbow.DesktopModules.AdminFSE.WebForm1 " %>
<HTML>
<script language="VB" runat="server">
Dim MyConnection As SqlConnection
Sub Page_Load(Sender As Object, E As EventArgs)
MyConnection = New SqlConnection("SERVER=MDS01; DATABASE=be; INTEGRATED SECURITY=false;PASSWORD=sa;USER=sa")
If Not (IsPostBack)
BindGrid()
End If
End Sub
Sub DataGrid1_Delete(Sender As Object, E As DataGridCommandEventArgs)
Dim MyCommand As SqlCommand
Dim DeleteCmd As String = "DELETE from Cargo_Solicitado where CargoID = @Id"
MyCommand = New SqlCommand(DeleteCmd, MyConnection)
MyCommand.Parameters.Add(New SqlParameter("@Id", SqlDbType.NVarChar, 11))
MyCommand.Parameters("@Id").Value = DataGrid1.DataKeys(CInt(E.Item.ItemIndex))
MyCommand.Connection.Open()
Try
MyCommand.ExecuteNonQuery()
Message.InnerHtml = "<b>Record Deleted</b><br>" & DeleteCmd
Catch Exc As SQLException
Message.InnerHtml = "ERROR: Could not delete record"
Message.Style("color") = "red"
End Try
MyCommand.Connection.Close()
BindGrid()
End Sub
Sub BindGrid()
Dim DS As DataSet
Dim MyCommand As SqlDataAdapter
MyCommand = New SqlDataAdapter("select * from Cargo_Solicitado", MyConnection)
DS = new DataSet()
MyCommand.Fill(DS, "Cargo_Solicitado")
DataGrid1.DataSource=DS.Tables("Cargo_Solicitado") .DefaultView
DataGrid1.DataBind()
End Sub
</script>
<body style="FONT: 10pt verdana">
<form runat="server" ID="Form1">
<h3><font face="Verdana">Deleting a Row of Data</font></h3>
<span id="Message" EnableViewState="false" runat="server" />
<p>
<ASP:DataGrid id="DataGrid1" runat="server" Width="800" BackColor="#ccccff" BorderColor="black"
ShowFooter="false" CellPadding="3" CellSpacing="0" Font-Name="Verdana" Font-Size="8pt" HeaderStyle-BackColor="#aaaadd"
DataKeyField="emp_id" OnDeleteCommand="DataGrid1_Delete">
<Columns>
<asp:ButtonColumn Text="Delete Employee" CommandName="Delete" />
</Columns>
</ASP:DataGrid>
</form>
</P>
</body>
</HTML>