小编hal*_*ldo的帖子

如何将List从视图传递到控制器 - MVC 4

从视图到控制器传递列表时我错过了一个小东西.它在控制器的[HttpPost]方法中显示null.任何人请指导我如何从视图到控制器获取列表数据.请查看下面的完整代码.

@model List<payorder_draft_printing.Models.registration>

@{
    ViewBag.Title = "bulk_approval";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<div class="container">

    <div class="row" style="text-align: left">

        <h2><u>Bulk Approval</u></h2>

        <br />
        <br />

        @using (Html.BeginForm("bulk_approval", "Sms", FormMethod.Post, new { enctype = "multipart/form-data" }))
        {
            <div style="width: 700px;" align="center">

                <table id="GetSerial" class="table">
                    <thead>
                        <tr class="ui-widget-header">
                            <th>Account Number</th>
                            <th>Mobile Number</th>
                            <th>Customer Name</th>
                            <th>Branch Code</th>
                            <th>Bulk Upload</th>
                            <th>Create Date</th>
                            <th>Created By</th>
                            <th>Active</th>
                           </tr>
                    </thead>

                    <tbody>

                        @if (Model != null)
                        {
                            foreach (var m in Model)
                            {
                            <tr style="height: 25px; border-bottom: 1px solid gray"> …
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc-4

3
推荐指数
1
解决办法
1万
查看次数

Xamarin.Forms bindingContext将源设置回root/parent

我得到了ViewModel一个AddToFavoriteCommand没有被调用的命令().现在它只关注命令,而CustomPin class不是viewModel.我设置我viewModelBindingContext代码页的后面.

但是因为它枚举了我的customPins集合,所以它会在那里查看命令.我需要回到根.我可能需要更改源但无法使其工作.

<ContentPage.Content>
    <StackLayout>
        <AbsoluteLayout>
            <Button Text="{Binding Filter}" Command="{Binding GotoFilterPageCommand}" />
        </AbsoluteLayout>
        <ListView x:Name="ListView" RowHeight="60" ItemsSource="{Binding CustomPins}" ItemSelected="OnItemSelected">
            <ListView.ItemTemplate>
                <DataTemplate>
                    <ViewCell>
                        <ViewCell.ContextActions>
                            <MenuItem Text="Favorite" Command="{Binding AddToFavoriteCommand}" />
                            <MenuItem Text="..." CommandParameter="{Binding .}" Clicked="OnMoreClicked" />
                        </ViewCell.ContextActions>
                        <StackLayout Padding="5" Orientation="Vertical" >
                            <Label Text="{Binding ParkingLot.Street}" FontSize="Medium" />
                        </StackLayout>
                    </ViewCell>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>
    </StackLayout>
</ContentPage.Content>
Run Code Online (Sandbox Code Playgroud)

代码背后(删除了所有其他逻辑,例如我不需要的点击事件)

[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class ParkingListPage : ContentPage
{
    public ParkingListPage()
    {
        InitializeComponent();
        BindingContext = new ParkingListViewModel(); …
Run Code Online (Sandbox Code Playgroud)

xaml xamarin xamarin.forms

3
推荐指数
1
解决办法
2633
查看次数

C#List &lt;string&gt;仅打印最后一个元素

我是C#的新手,并感谢我能获得的所有帮助。我有一个问题要打印列表中的所有元素,但是我只得到最后一个元素作为输出。如果我使用“ + =”而不是“ =”,那么我将所有元素都视为一行,这是我不喜欢的。

如何在自己的行上打印所有元素?

代码:

  public override string ToString()
  {        
        string combindedstring = string.Empty;

        foreach (string array in foodDescriptionList)
        {
            combindedstring = array;
        }      

        return combindedstring;
    }
Run Code Online (Sandbox Code Playgroud)

我也是这个网站的新手。如果有什么不适合我的问题,请告诉我。感谢所有帮助:)。

.net c# string visual-studio

3
推荐指数
1
解决办法
440
查看次数

FFImageLoading在Android中引发异常,错误为:System.TypeLoadException:由于找不到方法,因此无法加载方法替代列表:

我刚刚开始将FFImageLoading用于Xamarin跨平台项目,并且Android MainActivity.cs文件引发未处理的异常:

System.TypeLoadException:由于找不到方法而无法加载方法替代列表:void
Xamarin.Forms.Platform.Android.IVisualElementRenderer.add_LayoutChange(System.EventHandler`1)

我已经看过很多东西了,不知道该怎么做。这是我正在使用的版本:

  • Xamarin.Forms v3.6.0.264807
  • Xamarin.FFImageLoading v2.4.4.859
  • Xamarin.FFImageLoading.Forms v2.4.4.859

我了解版本必须正确才能解决此问题。

我会投入更多,但我没有几个小时来弄清楚如何正确使用该网站。我不断收到有关我的代码如何无法识别4个空格的错误(显然是!!!!!!!!!)。我只是想成功地解决这个问题。

c# xaml xamarin

3
推荐指数
1
解决办法
315
查看次数

C# HttpClient 在字典字符串/对象中使用 FormUrlEncodedContent 对象发布内容

我正在尝试将内容发布到我的服务器。这就是我过去一直这样做的方式,直到我不得不使用字符串以外的对象为止。

using (HttpClient client = new HttpClient())
{
    client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue(authType, tokens);
    var postParams = new Dictionary<string, object>();

    postParams.Add("string", string);
    postParams.Add("int", string);
    postParams.Add("datetime", DateTime);
    postParams.Add("datetime", DateTime);
    postParams.Add("Match", Match);
    postParams.Add("TicketId", token);

    using (var postContent = new FormUrlEncodedContent(postParams.ToDictionary()))
    {
        var myContent = JsonConvert.SerializeObject(postParams);
        var buffer = System.Text.Encoding.UTF8.GetBytes(myContent);
        var byteContent = new ByteArrayContent(buffer);
        byteContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");

        using (HttpResponseMessage response = await client.PostAsync(@"http://url/api", byteContent))
        {
            response.EnsureSuccessStatusCode(); // Throw if httpcode is an error
            using (HttpContent content = response.Content)
            {
                string result = …
Run Code Online (Sandbox Code Playgroud)

c# encoding json http httpclient

3
推荐指数
1
解决办法
8341
查看次数

ASP.NET Core 绑定区分大小写

我创建了 CRUD 控制器。创建模型时,我需要使用架构:

{ "id": int, "name": string }
Run Code Online (Sandbox Code Playgroud)

但控制器也绑定了模式

{ "Id": int, "Name": string }
Run Code Online (Sandbox Code Playgroud)

如何强制控制器仅绑定小写版本{ "id": int, "name": string }

c# binding asp.net-web-api asp.net-core

3
推荐指数
1
解决办法
8905
查看次数

我应该如何正确反序列化此对象?

我使用的API返回具有一些属性的公司符号的集合,但是我不知道如何反序列化它

{
    "A": {
        "advanced-stats": {
            "prop1": 0.198791,
            "prop2": 16.59,
            "prop3": 12.44,
        }
    },
    "AA": {
        "advanced-stats": {
            "prop1": 0.198791,
            "prop2": 16.59,
            "prop3": 12.44,
        }
    },
    "AAAU": {
        "advanced-stats": {
            "prop1": 0.198791,
            "prop2": 16.59,
            "prop3": 12.44,        
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

c# json json-deserialization asp.net-core

2
推荐指数
1
解决办法
56
查看次数

如何将包含错误土耳其语字符的字符串转换为显示正确的字符?

我有一个包含 ASCII 字符的字符串,例如

\n\n
"Tu%C4%9F%C3%A7e%20Kandemir%20-%20G%C3%BCl%C3%BC%20Soldurmam.mp3" \n
Run Code Online (Sandbox Code Playgroud)\n\n

正确的文件名是

\n\n
"Tu\xc4\x9f\xc3\xa7e Kandemir - G\xc3\xbcl\xc3\xbc Soldurmam" \n
Run Code Online (Sandbox Code Playgroud)\n\n

我该如何转换它?

\n

c# encoding

2
推荐指数
1
解决办法
2267
查看次数

在 Xamarin Android 中使用 TabbedPage.ToolbarPlacement="Bottom" 时如何更改 Tabbar 文本大小?

我在 Xamarin Forms 中有以下代码:

<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
            xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
            xmlns:local="clr-namespace:XXX;assembly=XXX"
            xmlns:android="clr-namespace:Xamarin.Forms.PlatformConfiguration.AndroidSpecific;assembly=Xamarin.Forms.Core"
            BackgroundColor="{DynamicResource BarBackgroundColor}"
            android:TabbedPage.ToolbarPlacement="Bottom"
            android:TabbedPage.BarItemColor="Gray"
            android:TabbedPage.BarSelectedItemColor="{DynamicResource BarSelectedItemColor}"
            android:TabbedPage.IsSwipePagingEnabled="False"
            x:Class="XXX.MainPage">
</TabbedPage>
Run Code Online (Sandbox Code Playgroud)

我想更改Android侧面Tabbar 文本的大小。我尝试创建自己的风格,如下所示:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="MyTabLayoutStyle" parent="TextAppearance.Design.Tab">
        <item name="android:textSize">5sp</item>
    </style>
</resources>
Run Code Online (Sandbox Code Playgroud)

而在我的Tabbar.axml

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.TabLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/tabs"
    android:layout_width="match_parent"
    app:tabGravity="fill" 
    app:tabMode="fixed"
    app:tabTextAppearance="@style/MyTabLayoutStyle"/>
Run Code Online (Sandbox Code Playgroud)

我有一种感觉这不起作用,因为我正在使用TabbedPage.ToolbarPlacement="Bottom"而不是使用TabLayout,我现在正在使用BottomNavigationView. 因此,上面的问题,如何在使用TabbedPage.ToolbarPlacement="Bottom".

xamarin.android xamarin xamarin.forms

1
推荐指数
1
解决办法
2870
查看次数

解决:AttributeError:模块“tensorflow”没有属性“app”

当我通过使用代码在 cmd 中使用代码时出现错误:

python generate_tfrecord.py --csv_input=images\train_labels.csv --image_dir=images\train --output_path=train.record""
Usage:
  # From tensorflow/models/
  # Create train data:
  python generate_tfrecord.py --csv_input=data/train_labels.csv  --output_path=train.record

  # Create test data:
  python generate_tfrecord.py --csv_input=data/test_labels.csv  --output_path=test.record
"""
from __future__ import division
from __future__ import print_function
from __future__ import absolute_import

import os
import io
import pandas as pd
import tensorflow as tf
from PIL import Image
from object_detection.utils import dataset_util
from collections import namedtuple, OrderedDict
flags = tf.compat.v1.flags
flags.DEFINE_string('csv_input', '', 'Path to the CSV input')
flags.DEFINE_string('output_path', '', 'Path to …
Run Code Online (Sandbox Code Playgroud)

object-detection python-3.x tensorflow

1
推荐指数
1
解决办法
6675
查看次数

Entity Framework Core + Linq:如何获得具有最大值的整个实体?寻找更优雅的解决方案

这是我到目前为止:

var TEST = await context.ProcessRevision.FirstOrDefaultAsync(i => i.ProcessRevId == (context.ProcessRevision.Max(i => i.ProcessRevId)));
Run Code Online (Sandbox Code Playgroud)

我不确定这是否是一个好的解决方案,或者我是否可以用更少的处理做一些更优雅的事情。

有什么建议?

c# linq entity-framework-core .net-core

0
推荐指数
1
解决办法
55
查看次数