provato...niente!sempre quel system byte finale
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<html>
<script language="C#" runat="server">
//string TotalRecords = "Documenti trovati: ";
SqlConnection myConnection;
protected void Page_Load(Object Src, EventArgs E)
{
myConnection = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Inetpub\\wwwroot\\repository\\App_Data\\database.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True");
if (!IsPostBack)
{
SqlDataAdapter myCommand = new SqlDataAdapter("select distinct categoria from tblCategory", myConnection);
DataSet ds = new DataSet();
myCommand.Fill(ds, "select");
MySelect.DataSource= ds.Tables["select"].DefaultView;
MySelect.DataBind();
}
}
public void btnFiltra_Click(Object sender, EventArgs E)
{
String selectCmd = "select * from upload where cognome = @cognome and tipo = @Tipo UNION select * from upload where Titolo = @Titolo and tipo = @Tipo";
SqlConnection myConnection = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Inetpub\\wwwroot\\repository\\App_Data\\database.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True");
SqlDataAdapter myCommand = new SqlDataAdapter(selectCmd, myConnection);
myCommand.SelectCommand.Parameters.Add(new SqlParameter("@cognome", 2));
myCommand.SelectCommand.Parameters["@cognome"].Value = tbFiltro.Text;
myCommand.SelectCommand.Parameters.Add(new SqlParameter("@Tipo", SqlDbType.VarChar, 50));
myCommand.SelectCommand.Parameters["@Tipo"].Value = MySelect.Value;
myCommand.SelectCommand.Parameters.Add(new SqlParameter("@Titolo", SqlDbType.VarChar, 50));
myCommand.SelectCommand.Parameters["@Titolo"].Value = MySelect.Value;
}
public void GetAuthors_Click(Object sender, EventArgs E)
{
String selectCmd = "select * from upload where cognome = @cognome and tipo = @Tipo UNION select * from upload where Titolo = @Titolo and tipo = @Tipo";
SqlConnection myConnection = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Inetpub\\wwwroot\\repository\\App_Data\\database.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True");
SqlDataAdapter myCommand = new SqlDataAdapter(selectCmd, myConnection);
myCommand.SelectCommand.Parameters.Add(new SqlParameter("@Tipo", SqlDbType.VarChar, 50));
myCommand.SelectCommand.Parameters["@Tipo"].Value = MySelect.Value;
myCommand.SelectCommand.Parameters.Add(new SqlParameter("@cognome", 2));
myCommand.SelectCommand.Parameters["@cognome"].Value = tbFiltro.Text;
myCommand.SelectCommand.Parameters.Add(new SqlParameter("@Titolo", 2));
myCommand.SelectCommand.Parameters["@Titolo"].Value = tbFiltro.Text;
DataSet ds = new DataSet();
myCommand.Fill(ds, "upload");
//TotalRecords += ds.Tables["upload"].Rows.Count.ToString();
MyDataList.DataSource = ds.Tables["upload"].DefaultView;
MyDataList.DataBind();
messaggio.Text = "ricerca effettuata!";
}
</script>
<head id="Head1" runat="server">
<title>ricerca</title>
<LINK href="mauro.css" rel=stylesheet>
</head>
<body style="font: 10pt verdana">
<form id="Form1" runat="server">
Immettere il nome autore pubblicazione <br/><br/>
<asp:TextBox id="tbFiltro" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator id="RequiredFieldValidator2" runat="server"
ControlToValidate="tbFiltro"
ErrorMessage="(*) Errore... immetere il nome dell'autore da cercare"
ForeColor="Red">
</asp:RequiredFieldValidator>
<BR><BR>
scegli la categoria dove cercare<br/><br/>
<select id="MySelect" DataTextField="Categoria" runat="server" style="width: 122px" datavaluefield="Categoria"/>
<input id="Submit1" type="submit" OnServerClick="GetAuthors_Click" Value="cerca" runat="server"/>
<asp:RequiredFieldValidator id="RequiredFieldValidator1" runat="server"
ControlToValidate="MySelect"
ErrorMessage="(*) Errore ... selezionare la categoria dove cercare!"
ForeColor="Red">
</asp:RequiredFieldValidator><p>
<asp:label id="messaggio" runat="server" ForeColor="red" Font-Bold="True"></asp:label>
<br /><br />
<table style="WIDTH: 500px; BORDER-COLLAPSE: collapse" cellspacing="0" border="1">
<tbody></tbody>
</table>
<div style="OVERFLOW: auto; WIDTH: 40%; HEIGHT: 250px">
<asp:DataList ID="MyDataList"
runat="server"
RepeatColumns="5"
EnableViewState="False"
RepeatLayout="Flow" Font-Bold="False"
Font-Italic="False" Font-Names="Verdana"
Font-Overline="False" Font-Strikeout="False"
Font-Underline="False" Font-Size="Smaller">
<ItemTemplate>
<b>Autore:</b><br />
<asp:Label ID="NomeLabel" runat="server" Width="100" Text='<%# Eval("Nome") %>'></asp:Label>
<asp:Label ID="CognomeLabel" runat="server" Width="100" Text='<%# Eval("Cognome") %>'></asp:Label><br />
<b>Titolo Pubblicazione:</b>
<b><i><font color="blue"">
<asp:Label ID="TitoloLabel" runat="server" Width="450" Text='<%# Eval("Titolo") %>'></asp:Label><br />
</i></b></font>
<b>Categoria:</b>
<asp:Label ID="TipoLabel" runat="server" Width="100" Text='<%# Eval("Tipo") %>'></asp:Label><br />
<b>Abstract:</b><br />
<asp:Label ID="AbstractLabel" runat="server" Width="400" Text='<%# Eval("Abstract") %>'></asp:Label>
<br />
<b>ISBN:</b>
<asp:Label ID="ISBNLabel" runat="server" Width="100" Text='<%# Eval("ISBN") %>'></asp:Label>
<b>ISNN:</b>
<asp:Label ID="ISNNLabel" runat="server" Width="100" Text='<%# Eval("ISNN") %>'></asp:Label><br />
<b>documento:</b>
<asp:Label ID="documentoLabel" runat="server" Width="100" Text='<%# Eval("contenttype") %>'></asp:Label>
<b>size:</b>
<asp:Label ID="sizeLabel" runat="server" Width="100" Text='<%# Eval("size") %>'></asp:Label><br />
<b>download:</b>
<asp:HyperLink ID="view" runat="server" Target=_blank
NavigateUrl='<%# "~/view_image.aspx?Doc_ID=" + DataBinder.Eval(Container.DataItem,"Doc_ID")+ Eval("documento").ToString() %>'
Text='<%# Eval("titolo") %>' /> <br />
<br />
</ItemTemplate>
<SeparatorStyle Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False"
Font-Underline="False" BackColor="Black" ForeColor="Black" HorizontalAlign="Center" Wrap="False" />
<ItemStyle BackColor="White" Font-Bold="False" Font-Italic="False" Font-Overline="False"
Font-Strikeout="False" Font-Underline="False" />
</asp:DataList><asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:databaseConnectionString8 %>"
SelectCommand="SELECT [Doc_ID], [Nome], [Cognome], [Dipartimento], [Titolo], [Data], [Tipo], [Keywords], [Abstract], [ISBN], [ISNN], [documento], [descrizione], [size], [contenttype] FROM [upload]">
</asp:SqlDataSource>
</form>
</body>
</html>