我正在使用formview插入數據到我的數據庫中。我必須使用文件上傳存儲圖像文件的名稱。代碼與textbox.I只需要指導如何連接通過表單視圖進行文件上傳。asp.net文件上傳值到文本框
代碼:
<asp:FormView ID="FormView1" runat="server" DataSourceID="SqlDataSource1"
DefaultMode="Insert">
<InsertItemTemplate>
Name:
<asp:TextBox ID="shop_nameTextBox" runat="server"
Text='<%# Bind("shop_name") %>' />
<br />
shop_image:
<asp:TextBox ID="shop_imageTextBox" runat="server"
Text='<%# Bind("shop_image") %>' />
<asp:FileUpload ID="FileUpload1" runat="server" />
<br />
shop_desc:
<asp:TextBox ID="shop_descTextBox" runat="server"
Text='<%# Bind("shop_desc") %>' />
<br />
shop_contact:
<asp:TextBox ID="shop_contactTextBox" runat="server"
Text='<%# Bind("shop_contact") %>' />
<br />
<asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True"
CommandName="Insert" Text="Insert" />
<asp:LinkButton ID="InsertCancelButton" runat="server"
CausesValidation="False" CommandName="Cancel" Text="Cancel" />
</InsertItemTemplate>
</asp:FormView>
我試圖連接文本框文件上傳控制,但徒勞無功。谷歌搜索也沒有回報。
您是否試圖從fileupload控件獲取文件名? – shanish
是的,我必須在文本框中獲取文件名。 – user2125727
只是'FileUpload1.FileName'會給你的文件名權嗎? – shanish