Ciao, ho provato a usatre il dataGrid come mi hai suggerito....
avrei una domanda..nelle righe dalla tabella, dovra comparire un
check box, pero puo darsi che un check box sia da associare a 2 righe (praticamente avrebbe colspan=2)..come faccio?
Ho fatto questo codice, ma ho un bottone(per ora come esempio poi
mettero un check box) per ogni riga:
PAGINA PROVA.ASPX
PAGINA PROVA.ASPX.CScodice:<%@ Page CodeBehind="AnnullaRichiesta.aspx.cs" Language="c#" AutoEventWireup="false" Inherits="Stefano.AnnullaRichiesta" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD </HEAD> <body bgcolor="white"> <form runat="server" ID="Form1"> <asp: Datagrid ID="MyDataGrid" AutogenerateColumns="false" CellPadding="2" BorderWidth="1" BorderColor="White" GridLines="vertical" OnItemCommnd="OnItemCommand" RunAt="server"> <Columns> <asp:BoundColumn HeaderText="Item ID" DataField="idRichiesta" /> <asp:ButtonColumn HeaderText="ACTION" Text="ADD TO" CommandName="AddToCart" /> </Columns> </asp: DataGrid> <asp:Label ID="Output" RunAt="server" /> </form> </body> </HTML>
codice:namespace Stefano { public class AnnullaRichiesta : System.Web.UI.Page { protected string strConn = "DRIVER={MySQL ODBC 3.51 Driver};SERVER=utp5n2-925;DATABASE=gestioneferie;UID=userferie;PWD=userferie;"; protected string Query; protected System.Web.UI.WebControls.DataGrid MyDataGrid; protected System.Data.DataSet Ds; protected Microsoft.Data.Odbc.OdbcConnection Conn; protected Microsoft.Data.Odbc.OdbcCommand command; private void Page_Load(object sender, System.EventArgs e) { if (!IsPostBack) { Conn = new Microsoft.Data.Odbc.OdbcConnection(strConn); try { Conn.Open(); Query = "select d.IdRichiesta "; Query = Query+"from gestioneferie.dettaglioRichiesta d"; command = new Microsoft.Data.Odbc.OdbcCommand(Query,Conn); reader = command.ExecuteReader(); MyDataGrid.DataSource = reader; MyDataGrid.DataBind(); } finally{Conn.Close();} } } // Put user code to initialize the page here #region Web Form Designer generated code override protected void OnInit(EventArgs e) { InitializeComponent(); base.OnInit(e); } private void InitializeComponent() { this.Load += new System.EventHandler(this.Page_Load); } #endregion } }

Rispondi quotando