标签: datatable

如何从C#中的数据表中删除一列?

我有这个代码:

public ActionResult RcColdis() {
    string constr = @"Data Source=192.168.52.197,1433;Network Library=DBMSSOCN;Initial Catalog=DB_ADRIAN;User ID=adrian;Password=password;";

    using (SqlConnection con = new SqlConnection(constr))
    {
        using (SqlCommand cmd = new SqlCommand("select a.secCode, b.[Haircut (%)],c.[Absolute IDR (Miliar)] from openquery(PDC_MYAPPS,'select secCode from mii.secReq')a left join (select * from RC_Saham)b on a.secCode=b.kode left join (select * from Absolute_IDR)c on b.kode=c.[Kode Saham]where b.[Haircut (%)] is not null union select a.code_Ic,a. PERC_HRCT, case  a. PERC_HRCT when 100 then 20 end from openquery(MANTARAY,'select b.code_ic, a.PERC_HRCT from cminstruments a, instrument_codes b where …
Run Code Online (Sandbox Code Playgroud)

c# sql-server asp.net-mvc datatable

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

选中复选框后删除链接

我有一个带有Datatable插件的表,当用户点击row(tr)时他会将其重定向到该链接.但我不希望用户在单击行上的复选框时被重定向到链接.这是html:

 <tr class="odd gradeX">
   <td class="number_elem_lang">
      <label class='with-square-checkbox2-mylist-details'>
      <input type='checkbox'>
      <span></span>
      </label>
   </td>
   <td class=""> ID022ox</td>
   <td class="list-name">First Lipsum List</td>
   <td class=""> 22 Candidates</td>
   <td class="">01 Apr 2016</td>
   <td><a href=""></a></td>
</tr>
Run Code Online (Sandbox Code Playgroud)

这是我的javascript代码,用于在点击用户时将用户重定向到链接:

$('#sample_1').on( 'click', 'tr', function() {
  var $a = $(this).find('a').last();
  if ( $a.length )
     window.location = $a.attr('href');
  } );
Run Code Online (Sandbox Code Playgroud)

因此,当单击复选框时,我不想重定向用户,请帮助:)

谢谢

html javascript datatable jquery

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

使用 primefaces 过滤器后获取空行键

在此输入图像描述当我没有在 primefaces 数据表中使用过滤器并尝试选择行时,例如按编辑它运行良好并获取所选行。但是当我使用 primefaces 过滤器然后选择过滤后的行然后编辑时,我得到了 org.primefaces.model。 SelectableDataModel 启用选择时出现异常。

我知道这意味着我有一个空行键,但我不知道为什么。我使用有效的行键(id)数据表的主键,当我使用调试时,我发现它两次获得 id失败的情况,第一次得到正确的过滤id,第二次得到空id。我的问题是为什么它两次获取 rowkey id,第二次获取 null 并导致异常

    <h:body>
    <h:form prependId="false" id="growlForm">
        <p:growl id="growl" showDetail="false" />
    </h:form>
    <h:form id="dataForm">
    <p:panel id="ingerdientsTable">
    <f:facet name="header">
          <h:outputText value="Standard Food List" />
        </f:facet>  
         <p:dataTable id="ingedientsTable" widgetVar="ingedientsTable" var="ingerdients" resizableColumns="true"
                    selectionMode="single" selection="#{mealBean.selectedStandardIngerdients}"
                     rowKey="#{ingerdients.getId()}" value="#{mealBean.allIngerdients}" rowsPerPageTemplate="5,10,25,50" rows="20"
                     paginator="true" style="padding-top:10px;padding-bottom:10px" tableStyle="table-layout: auto"
                     paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown} ">

                    <p:column headerText="Food Type"  filterBy="#{ingerdients.name}"><h:outputText value="#{ingerdients.name}" /></p:column>
                    <p:column headerText="Protein(gm)"  filterBy="#{ingerdients.containedProtiens}"><h:outputText value="#{ingerdients.containedProtiens}" /></p:column>
                    <p:column headerText="Carbs(gm)"  filterBy="#{ingerdients.containedCarbs}"><h:outputText value="#{ingerdients.containedCarbs}" /></p:column>
                    <p:column headerText="Fats(gm)"  filterBy="#{ingerdients.containedFats}"><h:outputText value="#{ingerdients.containedFats}" /></p:column>
                    <p:column …
Run Code Online (Sandbox Code Playgroud)

datatable jsf primefaces jsf-2

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

计算数据帧中每列的非NA值的数量

我有一个包含大量NAs和一些非Na值的大数据集.目前我计算NA每列的非值,如下所示:

 attach(df)
 1000 - (sum(is.na(X1)))
 1000 - (sum(is.na(X2)))
 1000 - (sum(is.na(X3)))
 1000 - (sum(is.na(X4)))
 1000 - (sum(is.na(X5)))
 ...
 detach(df)
Run Code Online (Sandbox Code Playgroud)

所以我的观察总长度 - 我的NA价值总和.

有没有更快的方法使用更少的代码行和打字工作,并让我快速概述所有列和非NA值的数量?

像for循环或什么?

我正在寻找这样的东西:

  X1     Amount of Non-Na-Values
  X2     ...
  X3     ...
  X4
  X5
  X6  
Run Code Online (Sandbox Code Playgroud)

谢谢 :)

datatable dataframe

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

需要帮助找出为什么 flutter 工具提示在我的代码中不起作用

我正在尝试将工具提示放入数据表中。但工具提示不起作用。

在这里,我按姓名、年龄和角色创建一个数据表。我使用工具提示栏网站来指示信息。我正在使用安卓工作室。任何帮助深表感谢!

这是颤振代码;请注意数据栏中的工具提示。

import 'package:flutter/material.dart';
    
    void main(){
      runApp(MyApp());
    }
    
    class MyApp extends StatelessWidget {
      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          debugShowCheckedModeBanner: false,
          home: Home(),
        );
      }
    }
    
    class Home extends StatefulWidget {
      @override
      _HomeState createState() => _HomeState();
    }
    
    class _HomeState extends State<Home> {
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          appBar: AppBar(
            title: Text("Data Table"),
          ),
          body: Center(
            child: DataTable(
              columns: [
                DataColumn(label: Text("Name"), tooltip: "Name"),
                DataColumn(label: Text("Age"), tooltip: "Age"),
                DataColumn(label: Text("Role"), tooltip: "Role")
              ],
              rows: [
                DataRow(cells: [ …
Run Code Online (Sandbox Code Playgroud)

datatable tooltip flutter

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

使用JSF,JDBC和HttpServlet在dataTable中搜索和检索数据

以下是我的代码我的bean

import java.util.logging.Level;
import java.util.logging.Logger;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;

/**
 *
 * @author utilisateur
 */
@ManagedBean(name="Beansearch")
@SessionScoped
public class Beansearch extends HttpServlet {
    ResultSet rs;
    private String cond;

    public String getcond() {
        return this.cond;
    }
    public void setcond(String cond) {
        this.cond= cond;
        }


   private List perInfoAll = new ArrayList();

    private int i;
public  List getperInfoAll(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException, SQLException {
    String value = req.getParameter("cond");
        try {
            Class.forName("oracle.jdbc.driver.OracleDriver"); …
Run Code Online (Sandbox Code Playgroud)

datatable jsf servlets jdbc

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

操作数类型冲突:日期与int C#不兼容

        private void monthCalendar1_DateChanged(object sender, DateRangeEventArgs e)
    {
        string strcon = "Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Users\\Fellipe\\documents\\visual studio 2010\\Projects\\WindowsFormsApplication2\\WindowsFormsApplication2\\PUBS.MDF;Integrated Security=True;Connect Timeout=30;MultipleActiveResultSets=True;User Instance=True";
        SqlConnection conexao = new SqlConnection(strcon);
        conexao.Open();
        SqlDataAdapter Buscar = new SqlDataAdapter("SELECT ROTA, DOCA FROM Planilha4 WHERE D2 =" + monthCalendar1.SelectionStart.ToString("dd/MM/yyyy"), conexao);
        DataTable dt = new DataTable();
        Buscar.Fill(dt);

       SqlDataAdapter sda = new SqlDataAdapter();
       BindingSource bSource = new BindingSource();

       bSource.DataSource = dt;
       dataGridView1.DataSource = bSource;
       sda.Update(dt);


    }
Run Code Online (Sandbox Code Playgroud)

抛出错误Buscar.Fill(dt);我想消除这个错误.我在等待回复.谢谢

c# sql datatable sql-server-express

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

汇总数据表中的行(分组依据)

我有一个像这样的数据表

ProductId CountThisWeek CountLastWeek
        1            10            15         
        1            20             5

        2             5            10
        2            10            15
        2            10            20

        3            10            15
Run Code Online (Sandbox Code Playgroud)

我需要通过“压缩”(按 productId 求和)我的初始数据表来获得一个新的数据表,如下所示:

ProductId CountThisWeek CountLastWeek
        1            30            20         
        2            25            45
        3            10            15
Run Code Online (Sandbox Code Playgroud)

有没有办法使用 LINQ 或其他技术来做到这一点(.NET 3.5)?

c# linq datatable linq-to-dataset

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

如何在html中创建嵌套表

我需要创建一个带有内表的 HTML 表,如下图所示:

[示例][1] 我很困惑是应该为左侧和右侧表创建两个单独的表还是将它们组合在一个表中

我尝试了下面的示例,但它没有以我想要的格式生成,基本上,它没有生成内部 HTML 表:

<table >

  <thead>
    <tr>
      <th>VITAL SIGNS</th>
      <th>FREQUENCY</th>
      <th></th>
      <th>TOTAL SUPPORT</th>
      <th>ASSIST</th>
      <th>SEE CARE</th>
      <th>FREQUENCY</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <th>Temperature</th>
      <th><input type="text" /></th>
      <th>SKIN CARE</th>
      <th></th>
      <th></th>
      <th></th>
      <th></th>
    </tr>
    <tr>
      <th>BP</th>
      <th><input type="text" /></th>
      <th>APPLY LOTION</th>
      <th><input type="checkbox" /></th>
      <th><input type="checkbox" /></th>
      <th><input type="checkbox" /></th>
      <th><input type="text" /></th>
    </tr>
    <tr>
      <th>Pulse</th>
      <th><input type="text" /></th>
      <th>ACTIVITY</th>
      <th></th>
      <th></th>
      <th></th>
      <th></th>
    </tr>
    <tr>
      <th>Respiration</th>
      <th><input type="text" /></th>
      <th><input type="checkbox" />
        <input type="checkbox" />
      </th> …
Run Code Online (Sandbox Code Playgroud)

html datatable html-table nested-table

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

如何在c#中编写简单的组sql查询到linq查询

我们只是通过db表上的查询来执行任何组

select sum(rs) from data where id=3;
Run Code Online (Sandbox Code Playgroud)

如何使用LINQ在datatable上编写类似的查询?

c# linq datatable

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

修剪DataTable的列名称

我如何修剪一个列名DataTable

假设列中的列名DataTable"Name ",我想将其更改为"Name".其他所有数据都不应该改变.怎么做?

c# datatable

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

实现ac#接口

我有一个名为myResult的dataTable,它有两列Process和ParentProcess,我试图把它放到一个Ienumerable类型中,所以我可以用Json.net序列化它.

原帖是这里的:

现在我到了这一点,我有这个界面:

namespace myFirstCProgramIn2013
    {
        public interface Interface1 : IEnumerable
        {
            string Process { get; set; }
            string ParentProcess { get; set; }
        }
    }
Run Code Online (Sandbox Code Playgroud)

我在这个类中实现了它:

public class myArray : Interface1
{

    public string Process
    {
        get
        {
            throw new NotImplementedException();
        }
        set
        {
            throw new NotImplementedException();
        }
    }

    public string ParentProcess
    {
        get
        {
            throw new NotImplementedException();
        }
        set
        {
            throw new NotImplementedException();
        }
    }

    public System.Collections.IEnumerator GetEnumerator()
    {
        throw new NotImplementedException();
    }
}
Run Code Online (Sandbox Code Playgroud)

然后我尝试使用此类使用以下代码将myResult分配给它:

   List<Interface1> recordList = …
Run Code Online (Sandbox Code Playgroud)

c# datatable interface

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

输入数组是否长于此表中的列数?

我今天整天都在收到这个错误,我看不出它是怎么发生的?我正在制作一个DataTable,它有7列,但是当我尝试将数组添加到表中时,我得到了错误.

这是代码;

    public static void BulkEntityInsert<T>(this T entity, List<T> entities)
    {
        //give array lenght
        string[] columns = new string[7];          

        DataTable dataTable = new DataTable();
        try
        {
            int jj = 0;
            DataColumn datecolumn = new DataColumn();
            foreach (PropertyDescriptor prop in TypeDescriptor.GetProperties(entity))
            {
                datecolumn.AllowDBNull = true;
                datecolumn.ColumnName = prop.Name == "Id" ? "ID" : prop.Name;
                datecolumn.DataType = Nullable.GetUnderlyingType(prop.PropertyType) ?? prop.PropertyType;
                columns[jj] = prop.Name == "Id" ? "ID" : prop.Name;                    
                jj++;
            }

            foreach (T t in entities)
            {
                // give the …
Run Code Online (Sandbox Code Playgroud)

c# datatable

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