Regarding Gridview displaying information

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi,
Can anyone let me know where in the below code for grid view i am going wrong?
using System;<br/>
using System.Collections.Generic;<br/>
using System.Linq;<br/>
using System.Web;<br/>
using System.Web.UI;<br/>
using System.Web.UI.WebControls;<br/>
using MySql.Data.MySqlClient;<br/>
using System.Diagnostics;<br/>
using System.Net;<br/>
using System.Net.Mail;<br/>
using System.IO;<br/>
using System.Text;<br/>
using GridViewClassLibrary;<br/>
<br/>
<br/>
namespace TOR_Tool<br/>
{<br/>
public partial class _Default : System.Web.UI.Page<br/>
{<br/>
protected void Page_Load(object sender, EventArgs e)<br/>
{<br/>
GridViewHelper helper = new GridViewHelper(GridView1);<br/>
helper.RegisterGroup("Subject", true, true);<br/>
helper.RegisterGroup("id", true, true);<br/>
helper.RegisterGroup("Created", true, true);<br/>
helper.RegisterGroup("Content", true, true); <br/>
helper.RegisterGroup("Status", true, true);<br/>
<br/>
helper.GroupHeader += new GroupEvent(helper_GroupHeader);<br/>
<br/>
<br/>
helper.ApplyGroupSort();<br/>
DataUtiliities dt = new DataUtiliities();<br/>
<br/>
GridView1.DataSource = dt.ExecuteDataSet("select distinct t.id,t.Subject,t.Status,max(t.created),replace(cast(Content as char),<br />,) as Content,max(a.created)
as Created,u.name from rt.Tickets t inner join rt.Transactions tr on tr.objecttype =RT::Ticket and tr.ObjectId = t.id inner join rt.Attachments a on a.transactionId = tr.id inner join rt.Users u on u.id = a.creator where status in (pending) and t.queue
= 4 and name != RT_System and Content not like %WordDocument% and Content not like %word% and Content not like %div% and Content not like %H001% and Content not like %&nbsp% group by t.Subject");<br/>
<br/>
GridView1.DataBind();<br/>
<br/>
}<br/>
private void helper_GroupHeader(string groupName, object[] values, GridViewRow row)<br/>
{<br/>
//row.BackColor = Color.AliceBlue;<br/>
row.Cells[0].Font.Bold = true;<br/>
row.Cells[0].Text = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + groupName + " &nbsp;&nbsp; - &nbsp;&nbsp;" + row.Cells[0].Text;<br/>
<br/>
}<br/>
protected void Button1_Click(object sender, EventArgs e)<br/>
{<br/>
MailMessage mail = new MailMessage();<br/>
mail.Body= GridViewToHtml(GridView1);
<br/>
mail.IsBodyHtml = true;<br/>
mail.Subject = "";<br/>
mail.To.Add("abc@xyz.com");<br/>
mail.From =new MailAddress ("ghi.corp@xyz.com");<br/>
SmtpClient smptp = new SmtpClient();<br/>
smptp.Host= "ghi.corp@xyz.com"; <br/>
smptp.DeliveryMethod = SmtpDeliveryMethod.Network; <br/>
smptp.Send(mail);<br/>
<br/>
<br/>
}<br/>
private string GridViewToHtml(GridView gv)<br/>
{<br/>
<br/>
StringBuilder sb = new StringBuilder();<br/>
StringWriter sw = new StringWriter(sb);<br/>
HtmlTextWriter hw = new HtmlTextWriter(sw);<br/>
gv.RenderControl(hw);<br/>
return sb.ToString();<br/>
}<br/>
public override void VerifyRenderingInServerForm(Control control)<br/>
{<br/>
//<br/>
}<br/>
<br/>
<br/>
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)<br/>
{<br/>
GridView1.PageIndex = e.NewPageIndex;<br/>
GridView1.DataBind();<br/>
}<br/>
<br/>
protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)<br/>
{<br/>
<br/>
}<br/>
}<br/>
}<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
aspx:<br/>
<br/>
<br/>
<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"<br/>
CodeBehind="Default.aspx.cs" Inherits="Tool._Default" EnableEventValidation="false" %><br/>
<br/>
<%--<asp:Content ID="Content1" runat="server" ContentPlaceHolderID="HeadContent <br/>
</asp:Content>--%><br/>
<asp:Content ID="Content2" runat="server" ContentPlaceHolderID="MainContent <br/>
<asp:Panel ID="pnlControls" runat="server <br/>
<table><br/>
<tr><br/>
<td><br/>
<asp:Label ID="lblShift" runat="server" Text="Shift:" Width="100px"
<br/>
Height="16px </asp:Label><br/>
</td><br/>
<td><br/>
<asp:DropDownList ID="ddlShift" runat="server <br/>
<asp:ListItem Text="1st Shift" Value="1 </asp:ListItem><br/>
<asp:ListItem Text="2nd Shift" Value="2 </asp:ListItem><br/>
<asp:ListItem Text="3rd Shift" Value="3 </asp:ListItem><br/>
</asp:DropDownList><br/>
</td> <br/>
</tr><br/>
<tr><br/>
<td colspan="2 <br/>
<asp:GridView ID="GridView1" runat="server" Height="50px" Width="800px" AutoGenerateColumns="false"<br/>
AllowPaging="true" OnPageIndexChanging="GridView1_PageIndexChanging" PageSize="50"<br/>
OnSorting="GridView1_Sorting <br/>
<Columns><br/>
<asp:BoundField DataField="id" HeaderText="id " /><br/>
<asp:BoundField DataField="Subject" HeaderText="Problem: " /><br/>
<asp:BoundField DataField="Status" HeaderText="Status" />
<br/>
<asp:BoundField DataField="created" HeaderText="Reported:" /><br/>
<asp:BoundField DataField="Content" HeaderText="Actions Performed: " /><br/>
</Columns><br/>
<RowStyle Height="40px" Width="250px" /><br/>
</asp:GridView><br/>
</td><br/>
</tr><br/>
<tr><br/>
<td><br/>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" /><br/>
</td><br/>
</tr><br/>
</table><br/>
</asp:Panel><br/>
</asp:Content><br/>
<asp:Content ID="Content3" runat="server" contentplaceholderid="HeadContent <br/>
<style type="text/css <br/>
.style1<br/>
{<br/>
width: 25px;<br/>
}<br/>
</style><br/>
</asp:Content><br/>

when i exceute the above code i get:
<br/>
Subject - CCL Freedom - RAU 1-3-4, 2-3-7, 2-4-7 RF path loss
<br/>
id - 4796
<br/>
Created - 10/14/2012 12:03:41 PM
<br/>
Content - Paul is making visit this week end. Send initial troubleshooting email to vessel. <br/>
Status - pending
<br/>
<br/>
<br/>
Subject - CEL Infinity - RAU 2-2-1 disconnected
<br/>
id - 5150
<br/>
Created - 8/29/2012 1:56:32 PM
<br/>
Content - The RAU 2-2-1 is disconnected. Sent initial troubleshooting email to the vessel.<br/>
<br/>
<br/>
Subject - CEL Summit - RAU 2-1-6 disconnected
<br/>
id - 5354
<br/>
Created - 10/18/2012 8:50:46 PM
<br/>
Content - Sent an initial troubleshooting email to the vessel.
<br/>

but i want to get the status for each and every grid like:
<br/>
Subject - CCL Freedom - RAU 1-3-4, 2-3-7, 2-4-7 RF path loss
<br/>
id - 4796
<br/>
Created - 10/14/2012 12:03:41 PM
<br/>
Content - Paul is making visit this week end. Send initial troubleshooting email to vessel. <br/>
Status - pending
<br/>
<br/>
<br/>
Subject - CEL Infinity - RAU 2-2-1 disconnected
<br/>
id - 5150
<br/>
Created - 8/29/2012 1:56:32 PM
<br/>
Content - The RAU 2-2-1 is disconnected. Sent initial troubleshooting email to the vessel.<br/>
Status - pending<br/>
<br/>
Subject - CEL Summit - RAU 2-1-6 disconnected
<br/>
id - 5354
<br/>
Created - 10/18/2012 8:50:46 PM
<br/>
Content - Sent an initial troubleshooting email to the vessel.
<br/>
Status - pending

Thanks!!
<hr class="sig rr

View the full article
 
Back
Top