Vaya con el datagrid de los ...

03/07/2004 - 15:56 por Xus | Informe spam
29 Líneas de codigo!!! (html + code behind)

<asp:DataGrid id="DataGrid1" runat="server" Height="42px" Font-Size="10px"
Font-Name="Verdana" AutoGenerateColumns="false" GridLines="Horizontal"
width="100%">
<Columns>
<asp:TemplateColumn HeaderStyle-BackColor="#ffcc66"
ItemStyle-BackColor="white">
<ItemTemplate>
<table width="16" height="16" bgcolor="white">
<tr>
<td><a href="noticies.aspx?borrar=<%#
Container.DataItem("idNoticia")%>"><img alt="Borrar notícia" border="0"
src="img/borrar.gif"></a></td>
<td><a href="noticiaDetallas.aspx?idNoticia=<%#
Container.DataItem("idNoticia")%>"><img alt="Llegir notícia" border="0"
src="img/lupa.gif"></a></td>
</tr>
</table>
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn HeaderStyle-BackColor="#ffcc66"
ItemStyle-BackColor="white" HeaderText="Titular Notícia"
DataField="titular"></asp:BoundColumn>
</Columns>
</asp:DataGrid>


' Connectem el DataGrid
Dim conn As OleDbConnection
Dim sql As OleDbCommand
Dim reader As OleDbDataReader

Dim cadena As String

cadena = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA Source=" &
Server.MapPath("dades.mdb")

conn = New OleDbConnection(cadena)
conn.Open()

sql = New OleDbCommand("SELECT idNoticia,titular FROM noticia",
conn)
reader = sql.ExecuteReader()

DataGrid1.DataSource = reader
DataGrid1.DataBind()

reader.Close()
conn.Close()


Vamos, que se han pasado un poco estos de microsoft esta vez no?
 

Leer las respuestas

#1 Franco Figún
03/07/2004 - 17:27 | Informe spam
Te da algun error ese codigo?

FF
www.francofigun.com.ar
www.microsofties.com.ar
MSN:
UIN: 314408886
Yahoo MSN:
"Xus" wrote in message
news:pzsgafor5bq1$
29 Líneas de codigo!!! (html + code behind)

<asp:DataGrid id="DataGrid1" runat="server" Height="42px" Font-Size="10px"
Font-Name="Verdana" AutoGenerateColumns="false" GridLines="Horizontal"
width="100%">
<Columns>
<asp:TemplateColumn HeaderStyle-BackColor="#ffcc66"
ItemStyle-BackColor="white">
<ItemTemplate>
<table width="16" height="16" bgcolor="white">
<tr>
<td><a href="noticies.aspx?borrar=<%#
Container.DataItem("idNoticia")%>"><img alt="Borrar notícia" border="0"
src="img/borrar.gif"></a></td>
<td><a href="noticiaDetallas.aspx?idNoticia=<%#
Container.DataItem("idNoticia")%>"><img alt="Llegir notícia" border="0"
src="img/lupa.gif"></a></td>
</tr>
</table>
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn HeaderStyle-BackColor="#ffcc66"
ItemStyle-BackColor="white" HeaderText="Titular Notícia"
DataField="titular"></asp:BoundColumn>
</Columns>
</asp:DataGrid>


' Connectem el DataGrid
Dim conn As OleDbConnection
Dim sql As OleDbCommand
Dim reader As OleDbDataReader

Dim cadena As String

cadena = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA Source=" &
Server.MapPath("dades.mdb")

conn = New OleDbConnection(cadena)
conn.Open()

sql = New OleDbCommand("SELECT idNoticia,titular FROM noticia",
conn)
reader = sql.ExecuteReader()

DataGrid1.DataSource = reader
DataGrid1.DataBind()

reader.Close()
conn.Close()


Vamos, que se han pasado un poco estos de microsoft esta vez no?

Preguntas similares