根据需要将File / s上载到Gridview行,并在上载后显示在同一列中

时间:2016-04-19 03:19:26

标签: c# asp.net gridview file-upload

我想将文件上传到Gridview中,并在上传完成后显示文件名。

下面是我生成Gridview的aspx文件。如何实现文件上传?提前谢谢。

<asp:CommandField ShowSelectButton="True" />
            <asp:BoundField DataField="Id" HeaderText="Id" SortExpression="Id"  />
            <asp:BoundField DataField="Date" HeaderText="Date" DataFormatString="{0:dd/MM/yyyy}" SortExpression  ="Date"  />
            <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
            <asp:BoundField DataField="Address" HeaderText="Address" SortExpression="Address" />
            <asp:BoundField DataField="Phone" HeaderText="Phone" SortExpression="Phone" />
            <asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />
            <asp:BoundField DataField="Source" HeaderText="Source" SortExpression="Source" />
            <asp:BoundField DataField="Message" HeaderText="Message" SortExpression  ="Message"  />

                <asp:TemplateField HeaderText="Upload">
                <ItemTemplate>
                    <asp:FileUpload ID="FileUpload1" runat="server" EnableViewState="true" />
                    <asp:Button ID="saveBtn" runat="server"  CommandArgument="<%# Container.DataItemIndex%>" CommandName="save"  Text="OK"/>
                </ItemTemplate>
            </asp:TemplateField>

1 个答案:

答案 0 :(得分:0)

check it do you want just this?

/**
 * Get the Location Detail from Fused Location API.
 * @param mContext
 * @return
 */
private Location getLocationDetails(Context mContext) {
    Location location = null;
    if (mGoogleApiClient != null) {
        if (ActivityCompat.checkSelfPermission(mContext, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(mContext, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
            Log.d(TAG,"Location Permission Denied");
            return null;
        }else {
            location = LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient);
        }
    }
    return location;
}

此代码简单地满足您的要求!