如何在Gridview中显示自定义数据 [英] How Do I Display Custom Data In Gridview

查看:122
本文介绍了如何在Gridview中显示自定义数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已检索事件日志数据
像eventid,eventsource,event日志,event time
如何在gridview或数据网格中显示这些值
我尝试使用Windows窗体进行工作,但是它需要在网页中显示,我该怎么做?

I have Retrieved event log data
like eventid,eventsource,event log ,event time
how can i display these values in gridview or data grid
i tried doing using a windows form it is working but i need to display it in a webpage how can i do this?

推荐答案

直接添加非数据绑定数据到C#/VB中的网格控件

It is straight forward to add non data-bound data to a grid control in C#/VB

private void dlgProbability_Load(object sender, EventArgs e)
{
    double P1 = Convert.ToDouble(m_Probabilities[0]) / Convert.ToDouble(m_Iterations) * 100;
    double P2 = Convert.ToDouble(m_Probabilities[1]) / Convert.ToDouble(m_Iterations) * 100;
    double P3 = Convert.ToDouble(m_Probabilities[2]) / Convert.ToDouble(m_Iterations) * 100;
    double P4 = Convert.ToDouble(m_Probabilities[3]) / Convert.ToDouble(m_Iterations) * 100;
    grdMain.Rows.Add(5);
    grdMain.Rows[0].Cells[0].Value = "1";
    grdMain.Rows[0].Cells[1].Value = P1.ToString("N4") + "%";
    grdMain.Rows[1].Cells[0].Value = "2";
    grdMain.Rows[1].Cells[1].Value = P2.ToString("N4") + "%";
    grdMain.Rows[2].Cells[0].Value = "3";
    grdMain.Rows[2].Cells[1].Value = P3.ToString("N4") + "%";
    grdMain.Rows[3].Cells[0].Value = "4";
    grdMain.Rows[3].Cells[1].Value = P4.ToString("N4") + "%";
    grdMain.Rows[4].Cells[0].Value = "Total";
    grdMain.Rows[4].Cells[1].Value = (P1 + P2 + P3 + P4).ToString("N2") + "%";
}


对不起,我错过了网页部分!
此代码在表中显示整个65,536个UNICODE字符.
不包括样式-粘贴到页面正文部分:

Sorry I missed the web page part!
This code display the entire 65,536 UNICODE characters in a table.
Styles not included - Paste into page body section:

document.write("<table>");

for(var i = 0; i < 4096; i++)

{

    document.write("<tr>")

    for(j = 0; j < 16; j++)

    {

        k++;

        document.write("<td>" + k + "<br/>" + "&#" + k + "</td>");
    }

    document.write("</tr>");
}

document.write("</table>");


请参阅以下示例

http://technico.qnownow.com/display-event-logs-in-gridview/ [ ^ ]
See this example

http://technico.qnownow.com/display-event-logs-in-gridview/[^]


这篇关于如何在Gridview中显示自定义数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆