Basandomi sulla vostra soluzione ho cercato di adattare la mia soluzione ma ottengo alcuni errori:
tabelle
Prodotti:
cod
descrizione
IDSottocategoria
Sottocategorie:
cod
IDCategoria
descrizione
private void Page_Load(object sender, System.EventArgs e)
{
...
if(!IsPostBack)
{
BindGrid();
}
}
protected void BindGrid()
{
// creo il DataSet per il DataGrid
GetSottoCategorie();
repCategorie.DataSource = DsDati.Tables["Categorie"].DefaultView;
repCategorie.DataBind();
}
public void GetProdotti(string categoria)
{
string query = "SELECT * FROM Prodotti WHERE IDSottocategoria='" + categoria.ToString() + "'";
try
{
DsDati = new DataSet();
String SQLProdotti = query;
OleDbDataAdapter myCommandProdotti = new OleDbDataAdapter(SQLProdotti,myConnection);
myCommandProdotti.SelectCommand.CommandType=Comman dType.Text;
myCommandProdotti.Fill(DsDati, "Prodotti");
myConnection.Close();
}
catch (Exception exc)
{
string debug = exc.Message;
}
}
public void GetSottoCategorie()
{
try
{
DsDati = new DataSet();
String SQLCat = "SELECT * FROM Sottocategorie IDCategoria Padre='S'";
OleDbDataAdapter myCommandCat = new OleDbDataAdapter(SQLCat,myConnection);
myCommandCat.SelectCommand.CommandType=CommandType .Text;
myCommandCat.Fill(DsDati, "Categorie");
myConnection.Close();
}
catch (Exception exc)
{
string debug = exc.Message;
}
}
Nel codice HTML
<asp:Repeater id="repCategorie" runat="server">
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "Descrizione") %></p>
<asp:Repeater id="repArticoli" runat="server" DataSource='<%# GetProdotti(DataBinder.Eval(Container.DataItem, "Cod")) %>'>
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "Descrizione") %>
</ItemTemplate>
</asp:Repeater>
</ItemTemplate>
</asp:Repeater>
Uno degli errori ottenuti è:
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS1502: The best overloaded method match for 'NewPatanegra.Salumi.GetProdotti(string)' has some invalid arguments
Source Error:
Line 16: <ItemTemplate>
Line 17:
<%# DataBinder.Eval(Container.DataItem, "Descrizione") %></p>
Line 18: <asp:Repeater id="repArticoli" runat="server" DataSource='<%# GetProdotti(DataBinder.Eval(Container.DataItem, "Cod")) %>'>
Line 19: <ItemTemplate>
Line 20: <%# DataBinder.Eval(Container.DataItem, "Descrizione") %
dove sbaglio???
:master: