我有以下控制器方法
public ActionResult Export(string [,] data, string workbookName)
{
ExcelWorkbook workbook = new ExcelWorkbook();
workbook.AddRows(data);
return new FileStreamResult(workbook.SaveSheet(), "application/vnd.ms-excel")
{
FileDownloadName = workbookName
};
}
Run Code Online (Sandbox Code Playgroud)
它采用二维数组并输出到工作表.
到目前为止,当从带有json数组的jquery发布时,我在data参数中获取除null之外的任何内容都失败了.有谁知道填充数据参数所需的正确json格式.我在Jquery 1.7.2上.
这是我的jquery
var arguments = {};
arguments.data = [["1"], ["2"], ["3"]];
arguments.workbookName = "test";
//Populate arrayOfValues
$.ajax({
type: "POST",
url: '/Excel/Export',
datatype: "json",
traditional: true,
data: arguments,
success: function (data) {
alert(data);
}
});
Run Code Online (Sandbox Code Playgroud) 我在C#中使用以下代码搜索LDAP以轮询用户的活动目录:
DirectoryEntry entry = new DirectoryEntry(ldapPath, userName, password);
DirectorySearcher Searcher = new DirectorySearcher(entry);
Searcher.CacheResults = true;
Searcher.SearchScope = SearchScope.Subtree;
Searcher.Filter = "(&(&(objectCategory=person)(objectClass=user))
(|(samaccountname=" + userSearch.SamAccountName + "*)
(&(GivenName=" + userSearch.FirstName + "*)(SN=" + userSearch.Surname +
"*))))";
Searcher.PropertiesToLoad.AddRange(new string[] {"DisplayName", "GivenName",
"DistinguishedName","Title","manager",
"mail", "physicalDeliveryOfficeName", "DirectReports", "Company",
"Description", "SAMAccountName"});
SearchResultCollection results = Searcher.FindAll();
List<ActiveUser> activeUsers = new List<ActiveUser>();
Run Code Online (Sandbox Code Playgroud)
我使用输入参数userSearch.FirstName ="jo"和userSearch.LastName ="bl"运行它,并期望一个用户"Joe Bloggs",但这没有出现在结果列表中.如果我使用Windows中的Active Directory用户和计算机工具中的名称文本框尝试此操作,则Joe Bloggs将显示为列表中的唯一用户.我正在使用正确的LDAP路径.我使用错误的过滤器来复制Windows工具中的功能吗?显示名称上是否有"喜欢"搜索?
任何帮助,将不胜感激.
我知道这很长,但请耐心等待.
我使用MVVM光框架在MVVM光样本中创建了一个非常类似于Laurent Bugnion的"MyFriends"程序的Windows应用商店程序.
在他的程序中,他使用gridview的SelectedItem属性来跟踪哪个项目是所选项目.
问题是,我让用户能够在GridView上选择多个项目,然后使用App Bar上的按钮对它们进行操作.对于此SelectedItem将无法正常工作.
有谁知道如何使用多选GridView进行此工作?我已经根据WPF上的一些文章尝试了GridViewItem的IsSelected属性,但这似乎不起作用.SelectedTimesheets getter在调用时总是返回空.这是我到目前为止:
MainPage.xaml(绑定到带有子TimesheetViewModel可观察集合的MainViewModel):
<GridView
x:Name="itemGridView"
IsItemClickEnabled="True"
ItemsSource="{Binding Timesheets}"
ItemTemplate="{StaticResource TimesheetTemplate}"
Margin="10"
Grid.Column="0"
SelectionMode="Multiple"
helpers:ItemClickCommand.Command="{Binding NavigateTimesheetCommand}" RenderTransformOrigin="0.738,0.55" >
<GridView.ItemContainerStyle>
<Style TargetType="GridViewItem">
<Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}"/>
</Style>
</GridView.ItemContainerStyle>
</GridView>
Run Code Online (Sandbox Code Playgroud)
MainViewModel(从完整代码中删除):
public class MainViewModel : ViewModelBase
{
private readonly IDataService _dataService;
private readonly INavigationService _navigationService;
/// <summary>
/// Initializes a new instance of the MainViewModel class.
/// </summary>
public MainViewModel(IDataService dataService, INavigationService navigationService)
{
_dataService = dataService;
_navigationService = navigationService;
Timesheets = new ObservableCollection<TimesheetViewModel>();
ExecuteRefreshCommand();
} …
Run Code Online (Sandbox Code Playgroud)