Asp.net 从e.Row.DataItem分配数据

Asp.net 从e.Row.DataItem分配数据,asp.net,Asp.net,由于我是asp新手,我在基于e.Row.DataItem的分配方面遇到了一个小问题。 代码: 注意:这里e.Row.DataItem有数据(通过放置断点来查看),但当执行此操作时,不会为allTicket分配任何数据 请还原解决方案您是否确定存储在e.Row.DataItem中的数据类型为All\u Ticket?我如何知道数据类型为All\u Ticket typee.Row.DataItem包含ticketid、appname、appid等数据。我使用ASP.NET已有一段时间了,但是我想如

由于我是asp新手,我在基于e.Row.DataItem的分配方面遇到了一个小问题。 代码:

注意:这里e.Row.DataItem有数据(通过放置断点来查看),但当执行此操作时,不会为allTicket分配任何数据


请还原解决方案

您是否确定存储在
e.Row.DataItem
中的数据类型为
All\u Ticket
?我如何知道数据类型为All\u Ticket typee.Row.DataItem包含ticketid、appname、appid等数据。我使用ASP.NET已有一段时间了,但是我想如果你在这一行的
All\u Ticket allTicket=e.Row.DataItem作为All\u Ticket
,将鼠标悬停在
.DataItem
上,它可能会告诉你类型是什么。现在我想不起来这是否有效,但请尝试一下,至少我们可以将其作为一个选项删除。是的。dataitem中的数据与All_票证的类型相同
protected void grdStaffReport_RowDataBound(object sender, GridViewRowEventArgs e)
{
    ApplicationRegistration appReg = new ApplicationRegistration();

    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        All_Ticket allTicket = e.Row.DataItem as All_Ticket;
        if (allTicket != null)
        {
            Label lblTicketId = ((Label)e.Row.FindControl("lblTicketId"));
            lblTicketId.Text = "PHDT" + allTicket.TicketId;
            Label lblStartedBy = ((Label)e.Row.FindControl("lblStartedBy"));
            lblStartedBy.Text = this.GetTicketStartBy(allTicket.ClientId);
            HyperLink hylnk = (HyperLink)e.Row.FindControl("HyperLink1");
            hylnk.NavigateUrl = "~/User/DisplayTicket.aspx?TicketId=" + allTicket.TicketId + " &AppId=" + allTicket.AppId;
            Label lblIsCloesed = ((Label)e.Row.FindControl("lblIsCloesed"));
            if (allTicket.isClosed == true)
            {
                hylnk.ForeColor = System.Drawing.Color.Green;
                lblIsCloesed.Text = "Yes";
            }
            else
            {
                lblIsCloesed.Text = "No";
                hylnk.ForeColor = System.Drawing.Color.Blue;
            }
            Label lblLastUpdateBy = ((Label)e.Row.FindControl("lblLastUpdateBy"));
            lblLastUpdateBy.Text = this.GetTicketLastUpdateBy(allTicket.TicketId, lblStartedBy.Text);
            TicketRegistration ticReg = new TicketRegistration();
            Ticket_Reply tic = ticReg.GetMaxTicketByTicketId(allTicket.TicketId);
            Label lblUpdationDt = (Label)e.Row.FindControl("lblUpdationDt");
            Label lblclient = (Label)e.Row.FindControl("lblClint");
            var user = userManage.GetClientUserByUserId(allTicket.ClientId);
            lblclient.Text = _clientReg.GetClientNameByID(user.ParentId);
            if (tic != null)
            {
                lblUpdationDt.Text = Convert.ToString(tic.CreationDt);
            }
            else
            {
                lblUpdationDt.Text = Convert.ToString(allTicket.CreationDt);
            }

            Label lblAppId = ((Label)e.Row.FindControl("lblApplicaton"));
            lblAppId.Text = appReg.GetAppNameByID(allTicket.AppId);

            Label lblSNo = ((Label)e.Row.FindControl("lblSno"));
            lblSNo.Text = (++i).ToString();
        }
    }
}