小编Jun*_*son的帖子

获取CheckBox.Checked在ASPxGridView中没有正确地进行Woking

我在ASPxGridView中有这样的复选框:

<dxwgv:ASPxGridView ID="Grid_Loading_Plan_Detail" runat="server" >          
...
<dxwgv:GridViewDataColumn Caption="#" VisibleIndex="1">
<DataItemTemplate>
<dxe:ASPxCheckBox ID="loadingStatus" runat="server" Checked='<%# GetChecked(Eval("loadingStatus").ToString()) %>'></dxe:ASPxCheckBox>
</DataItemTemplate>
</dxwgv:GridViewDataColumn>
...
</dxwgv:ASPxGridView>
Run Code Online (Sandbox Code Playgroud)

它在加载复选框时很好地绑定,这里的函数:

Public Function GetChecked(value As String) As Boolean
    Select Case value
        Case "1"
            Return True
        Case "0"
            Return False
        Case Else
            Return False
    End Select
End Function
Run Code Online (Sandbox Code Playgroud)

问题是,当检查checked状态时,它总是返回加载的值.如果状态是checked第一次加载然后我执行uncheckedCheckBox,它仍然会返回checked.这里我如何获取值并将其保存到数据库:

Protected Sub btSimpan_Click(sender As Object, e As EventArgs) Handles btSimpan.Click
    Try
        sqlstring = ""
        For i As Integer = 0 To Grid_Loading_Plan_Detail.VisibleRowCount - 1 …
Run Code Online (Sandbox Code Playgroud)

asp.net aspxgridview

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

在Visual Studio 2017中发布时,CSS链接损坏

我在发布Visual Studio 2017,C#,ASP.Net MVC 5项目时遇到问题.我发布以下设置:

在此输入图像描述 在此输入图像描述

CSS内容链接问题,例如bootstrap:

@font-face{font-family:'Glyphicons Halflings';src:url(../fonts/glyphicons-halflings-regular.eot);
Run Code Online (Sandbox Code Playgroud)

如果bootstrap.min.css位于localhost/bower_components/css/bootstraps/bootstrap.min.css,那css将显示为localhost/fonts/glyphicons-halflings-regular.eot客户端.

如果我只是复制粘贴所有项目而不将其发布到服务器,链接将正确显示为 localhost/bower_components/css/fonts/glyphicons-halflings-regular.eot

所有css都会发生这种情况,包括css中的图像和其他文件.

c# asp.net-mvc-5 visual-studio-2017

9
推荐指数
2
解决办法
524
查看次数

Symfony2中隐藏的实体字段类型

我想在控制器中为我的外键实体创建一个隐藏值.

我以前的控制器是这样的(工作正常):

->add('id_grup', 'entity', array('class' => 'Sifo\AdminBundle\Entity\MstGrup'))
Run Code Online (Sandbox Code Playgroud)

我想为我的表单分配一个隐藏值,如下所示:

->add('id_grup', 'hidden', array('data' => $id))
Run Code Online (Sandbox Code Playgroud)

但它给了我一个错误:

ContextErrorException:Catchable Fatal Error:传递给Sifo\AdminBundle\Entity\DftGrupMapel :: setIdGrup()的参数1必须是Sifo\AdminBundle\Entity\MstGrup的实例,给定字符串,在C:\ Sifony\vendor\symfony\symfony中调用第360行的\ src\Symfony\Component\PropertyAccess\PropertyAccessor.php,在C:\ Sifony\src\Sifo\AdminBundle\Entity\DftGrupMapel.php第179行中定义

如何为隐藏的外键实体赋值?非常感谢你.

symfony

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

不使用symfony2格式更新数据

我很抱歉,如果这个问题有点新手,但我尝试搜索有关更新symfony中的数据,但看起来所有教程都需要很少的正常步骤来执行此操作:

  1. 经理初始化 $em = $this->getDoctrine()->getManager();
  2. 使用条件创建实体 $entity = $em->getRepository('bundle')->find($id);
  3. 创建表单 $form = $this->createForm(new Type(), $entity);
  4. 与请求绑定 $editForm->handleRequest($request);
  5. 刷新数据 $em->flush();

假设我在twig中有自定义表单并在控制器中执行手动getRequest $variable = $request->request->get('name');.有没有办法在$entity = $em->getRepository('bundle')->find($id);不创建表格来刷新我的数据的情况下更新实体中特定ID的数据?因为我需要使用迭代为我的数据库中的许多ID更新此变量.假设我需要使用此值更新数千个数据.如果创建表单会影响性能和时间,我很担心.

谢谢你的回复.

symfony

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

WHERE IN子句AS对象实体框架

如果我有一个Company对象:

var companies = db.Companies.Where(...);
Run Code Online (Sandbox Code Playgroud)

和一个UserCompany对象相关的对象one-to-many:

var users = db.Users.Where(...);
Run Code Online (Sandbox Code Playgroud)

我怎样才能达到像这样的标准 select * from users where user.company in (company)

从一些文章中读到,我尝试过类似的东西:

users.Where(x => companies.Contains(x.company))
Run Code Online (Sandbox Code Playgroud)

但似乎不起作用.我错过了什么?

编辑

确切答案:

public PartialViewResult IndexGrid(String search)
{
    var companies = db.Users.Find(User.Identity.GetUserId()).Companies.AsQueryable();
    Guid[] guids = companies.Select(c => c.Id).ToArray();

    if (String.IsNullOrEmpty(search))
        return PartialView("_IndexGrid", db.Set<Quotation>().OrderByDescending(x => x.Code).AsQueryable()
            .Where(x => guids.Contains(x.Company.Id)));
    else
        return PartialView("_IndexGrid", db.Set<Quotation>().OrderByDescending(x => x.Code).AsQueryable()
            .Where(x => guids.Contains(x.Company.Id))
            .Where(x => x.Code.Contains(search)|| x.MasterCustomer.Name.Contains(search)));
}
Run Code Online (Sandbox Code Playgroud)

c# linq entity-framework-6

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