Click here to Skip to main content
15,897,704 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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?
Posted
Comments
ZurdoDev 20-Aug-14 14:44pm    
Just about the same way you do it in windows form. Put a grid on your page and bind it to your datasource.

Where are you stuck?
Chinna Suresh 20-Aug-14 14:50pm    
am unable to add custom coloumns and rows using gridview
Chinna Suresh 20-Aug-14 14:55pm    
string query = "*[System/EventID=535]";
EventLogQuery eventsQuery = new EventLogQuery("Application", PathType.LogName, query);
try
{
EventLogReader logReader = new EventLogReader(eventsQuery);

for (EventRecord eventInstance = logReader.ReadEvent();
null != eventInstance; eventInstance = logReader.ReadEvent())
{
DataRow rd = this.myTable.NewRow();


rd[0] = eventInstance.Id.ToString();
rd[1] = eventInstance.ProviderName.ToString();

try
{
rd[2] = eventInstance.FormatDescription().ToString();
}
catch (EventLogException)
{
// The event description contains parameters, and no parameters were
// passed to the FormatDescription method, so an exception is thrown.

}

// Cast the EventRecord object as an EventLogRecord object to
// access the EventLogRecord class properties
EventLogRecord logRecord = (EventLogRecord)eventInstance;
rd[3] =logRecord.ContainerLog.ToString();
this.myTable.Rows.Add(rd);
here is my code for form
MONU MITTAL 21-Aug-14 0:40am    
simply take a grid view on webpage and bind it.
all the functioning like window form is performed on them.
you can bind it at on pageload or static time by clicking on ">" that is appear on the grid view

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

C#
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") + "%";
}
 
Share this answer
 
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:

XML
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>");
 
Share this answer
 
 
Share this answer
 
Comments
Chinna Suresh 21-Aug-14 3:33am    
for (EventRecord eventInstance = logReader.ReadEvent();
null != eventInstance; eventInstance = logReader.ReadEvent())
{
DataRow rd = this.myTable.NewRow();


eventInstance.Id.ToString();
eventInstance.ProviderName.ToString();

try
{
eventInstance.FormatDescription().ToString();
}
catch (EventLogException)
{
// The event description contains parameters, and no parameters were
// passed to the FormatDescription method, so an exception is thrown.

}

// Cast the EventRecord object as an EventLogRecord object to
// access the EventLogRecord class properties
EventLogRecord logRecord = (EventLogRecord)eventInstance;
logRecord.ContainerLog.ToString();


Here is my code i need to display eventinstance data into grid view am unable to do that..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900