本文介绍了ASP.NET,如何在detailsview内绑定文件上传控件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨
我在mssql中有一个常规数据库,该数据库具有Products表,Products中的字段之一是"ImgURL",我想将该字段绑定到DetailsView中的FileUpload控件.
如何完成的?
我已经在需要时将所有标签的ImgUrl Filed模板化为FileUpload控件.
Hi
I''ve got regular DB in mssql that has Products table , one of the fields inside Products is "ImgURL" , I want to bind that field to FileUpload control inside the DetailsView .
How its done ?
I already templated the ImgUrl Filed from all label to FileUpload control when needed.
<pre lang="xml"><asp:DetailsView ID="DetailsView1" runat="server" Height="50px" Width="125px" AutoGenerateRows="False"
DataKeyNames="ProductID" DataSourceID="EntityDataSource1"
AllowPaging="True" BackColor="LightGoldenrodYellow" BorderColor="Tan"
BorderWidth="1px" CellPadding="2" ForeColor="Black" GridLines="None"
oniteminserted="DetailsView1_ItemInserted"
onpageindexchanged="DetailsView1_PageIndexChanged">
<AlternatingRowStyle BackColor="PaleGoldenrod" />
<EditRowStyle BackColor="DarkSlateBlue" ForeColor="GhostWhite" />
<Fields>
<asp:BoundField DataField="ProductID" HeaderText="ProductID" ReadOnly="True" SortExpression="ProductID" />
<asp:BoundField DataField="ProductName" HeaderText="ProductName" SortExpression="ProductName" />
<asp:TemplateField HeaderText="CategoryID" SortExpression="CategoryID">
<EditItemTemplate>
<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="EntityDataSource2"
DataTextField="CategoryName" DataValueField="CategoryID" Text=''<%# Bind("CategoryID") %>''>
</asp:DropDownList>
</EditItemTemplate>
<InsertItemTemplate>
<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="EntityDataSource2"
DataTextField="CategoryName" DataValueField="CategoryID" Text=''<%# Bind("CategoryID") %>''>
</asp:DropDownList>
</InsertItemTemplate>
<ItemTemplate>
<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="EntityDataSource2"
DataTextField="CategoryName" DataValueField="CategoryID" Text=''<%# Bind("CategoryID") %>''>
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="UnitPrice" HeaderText="UnitPrice" SortExpression="UnitPrice" />
<asp:BoundField DataField="UnitsInStock" HeaderText="UnitsInStock" SortExpression="UnitsInStock" />
<asp:BoundField DataField="UnitsOnOrder" HeaderText="UnitsOnOrder" SortExpression="UnitsOnOrder" />
<asp:TemplateField HeaderText="ImageUrl" SortExpression="ImageUrl" >
<EditItemTemplate>
<asp:FileUpload ID="FileUpload1" runat="server" />
</EditItemTemplate>
<InsertItemTemplate>
<asp:FileUpload ID="FileUpload1" runat="server"/>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="FileUpload1" runat="server" DataSourceID="EntityDataSource1" Text=''<%# Bind("ImageUrl") %>''/>
</ItemTemplate>
</asp:TemplateField
>
>
推荐答案
这篇关于ASP.NET,如何在detailsview内绑定文件上传控件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!