Products.aspx:
<table>
<tr>
<td><asp:Label ID="Label2" runat="server" Text="Brand"></asp:Label></td>
<td>
<asp:DropDownList ID="DropDownList1"
runat="server" DataSourceID="SqlDataSource1" DataTextField="Brand"
DataValueField="Brand">
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:HandheldConnect %>"
SelectCommand="SELECT DISTINCT [Brand] FROM [Product1]"></asp:SqlDataSource>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label3" runat="server" Text="Model"></asp:Label></td>
<td>
<asp:TextBox ID="ModelTextBox" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td>
<asp:Label ID="Label6" runat="server" Text="Description"></asp:Label></td>
<td>
<asp:TextBox ID="DescriptionTextBox" runat="server" TextMode="MultiLine"
Height="102px" Width="288px"></asp:TextBox></td>
</tr>
<tr>
<td>
<asp:Label ID="Label4" runat="server" Text="Quantity"></asp:Label></td>
<td>
<asp:TextBox ID="QuantityTextBox" runat="server" onkeypress="return AcceptNumericOnly(event, false);"></asp:TextBox></td>
</tr>
<tr>
<td><asp:Label ID="Label5" runat="server" Text="Price"></asp:Label></td>
<td><asp:TextBox ID="PriceTextBox" runat="server" onkeypress="return AcceptNumericOnly(event, false);"></asp:TextBox></td>
</tr>
<tr>
<td>
<asp:Label ID="Label1" runat="server" Text="Image"></asp:Label></td>
<td>
<asp:FileUpload ID="ImageUpload" runat="server" />
</tr>
<tr>
<td></td>
<td>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
<asp:Button ID="Button2" runat="server" Text="Delete" />
</td>
</tr>
<tr>
<td>
<asp:Label ID="StatusLabel" runat="server" Text="Status:"></asp:Label> </td>
<td>
<asp:Label ID="StatusTextLabel" runat="server" Text="No operation performed"></asp:Label> </td>
</tr>
</table>
Products.aspx.cs:
protected void Button1_Click(object sender, EventArgs e)
{
if (ImageUpload.HasFile)
{
string str = ImageUpload.FileName;
ImageUpload.PostedFile.SaveAs(Server.MapPath(".") + "//Images/Mobiles/Samsung//" + str);
string path = str;
conn.Open();
SqlCommand cmd = new SqlCommand("insert into Product1(Brand,Model,Description,Price,Image) values('" + HBrand + "','" + ModelTextBox.Text + "','" + DescriptionTextBox.Text + "','" + PriceTextBox.Text + "','" + path + "')", conn);
cmd.ExecuteNonQuery();
conn.Close();
StatusTextLabel.Text = "Uploaded" + HBrand + "product";
}
else
{
StatusTextLabel.Text = "Please Choose a file";
}
}
}
button1_click从不触发,但页面显示&#34;网页无法显示&#34;。如果我的文件位于&#34;图像/手机/三星&#34;?
,那么地图路径应该是什么?请帮忙