【问题标题】:Show only rows that contains specific value in specific row仅显示特定行中包含特定值的行
【发布时间】:2020-07-31 19:00:54
【问题描述】:

我只需要对所有行进行排序,以便在userId 列中显示包含相同Session["ID"] 的行。

这是我的代码

public void GetAllUsers()
{
    Response.Write("<table border='1' class='tables'> <tr>");
    Response.Write("<td align='center'>שם המשימה</td>");
    Response.Write("<td align='center'>פירוט המשימה</td>");
    Response.Write("<td align='center'>מועד אחרון</td>");

    foreach (DataRow row in ds.Tables[0].Rows)
    {
        Response.Write("<tr>");
        Response.Write("<td align='center'>" + row["title"].ToString() + "</td> ");
        Response.Write("<td align='center'>" + row["description"].ToString() + "</td> ");
        Response.Write("<td align='center'>" + row["isDone"].ToString() + "</td> ");
        Response.Write("</tr>");
    }

    Response.Write("</table>");
}

【问题讨论】:

    标签: c# html sql asp.net datatable


    【解决方案1】:

    你的意思是:

    foreach (DataRow row in ds.Tables[0].Rows)
    {
         if (row["userid"].ToString() == Session["ID"].ToString())
         { 
             Response.Write("<tr>");
             Response.Write("<td align='center'>" + row["title"].ToString() + "</td> ");
             Response.Write("<td align='center'>" + row["description"].ToString() + "</td> ");
             Response.Write("<td align='center'>" + row["isDone"].ToString() + "</td> ");
             Response.Write("</tr>");
         }   
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-12-08
      • 1970-01-01
      • 1970-01-01
      • 2021-11-26
      • 1970-01-01
      • 1970-01-01
      • 2023-03-20
      相关资源
      最近更新 更多