현재 컬렉션에 바인딩 된 gridview가 있습니다. 'RowCreated'이벤트 내에서 html (특정 필드에 취소 선을 추가)을 조작하고 있습니다.Gridview를 정렬 한 후 왜 rowcreated 이벤트가 시작되지 않습니까?
이 모든 페이지로드에 잘 작동하지만 열을 정렬 할 때마다 RowCreated 이벤트가 발생하지 않는 것 같습니다.
어떻게 수정합니까?
편집 : 여기에 내가 여기
protected void gvResults_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (e.Row.DataItem != null)
{
Property currentProperty = (Property)e.Row.DataItem;
e.Row.Attributes.Add("id", currentProperty.Id.ToString());
Document propertyDoc = new Document(currentProperty.Id);
if (currentProperty.Price == 0)
{
e.Row.Cells[5].Controls.Clear();
e.Row.Cells[5].Controls.Add(new Literal() { Text = "N/A" });
}
if (propertyDoc.getProperty("floorPlan").Value == null || propertyDoc.getProperty("floorPlan").Value.ToString() == "")
{
e.Row.Cells[6].Controls.Clear();
e.Row.Cells[6].Controls.Add(new Literal() { Text = "View" });
}
if (propertyDoc.getProperty("propertyImage").Value == null || propertyDoc.getProperty("propertyImage").Value.ToString() == "")
{
e.Row.Cells[7].Controls.Clear();
e.Row.Cells[7].Controls.Add(new Literal() { Text = "View" });
}
if (currentProperty.Reserved == true)
{
e.Row.ForeColor = System.Drawing.ColorTranslator.FromHtml("#999999");
e.Row.Cells[1].Text = currentProperty.DevelopmentName;
e.Row.Cells[2].Text = currentProperty.LocationDisplayText;
e.Row.Cells[3].Text = currentProperty.PropertyTypeName;
e.Row.Cells[4].Text = currentProperty.BedroomsDisplayText;
e.Row.Cells[5].Controls.Clear();
e.Row.Cells[5].Controls.Add(new Literal() { Text = "RESERVED" });
//e.Row.Cells[6].Controls.Clear();
//e.Row.Cells[6].Controls.Add(new Literal() { Text = "<del>View</del>" });
//e.Row.Cells[7].Controls.Clear();
//e.Row.Cells[7].Controls.Add(new Literal() { Text = "<del>View</del>" });
}
else if (currentProperty.Sold == true)
{
e.Row.ForeColor = System.Drawing.ColorTranslator.FromHtml("#999999");
e.Row.Cells[1].Text = currentProperty.DevelopmentName;
e.Row.Cells[2].Text = currentProperty.LocationDisplayText;
e.Row.Cells[3].Text = currentProperty.PropertyTypeName;
e.Row.Cells[4].Text = currentProperty.BedroomsDisplayText;
e.Row.Cells[5].Controls.Clear();
e.Row.Cells[5].Controls.Add(new Literal() { Text = "SOLD" });
//e.Row.Cells[6].Controls.Clear();
//e.Row.Cells[6].Controls.Add(new Literal() { Text = "<del>View</del>" });
//e.Row.Cells[7].Controls.Clear();
//e.Row.Cells[7].Controls.Add(new Literal() { Text = "<del>View</del>" });
}
else if (currentProperty.Released == true)
{
e.Row.ForeColor = System.Drawing.ColorTranslator.FromHtml("#999999");
e.Row.Cells[1].Text = currentProperty.DevelopmentName;
e.Row.Cells[2].Text = currentProperty.LocationDisplayText;
e.Row.Cells[3].Text = currentProperty.PropertyTypeName;
e.Row.Cells[4].Text = currentProperty.BedroomsDisplayText;
e.Row.Cells[5].Controls.Clear();
e.Row.Cells[5].Controls.Add(new Literal() { Text = "TO BE RELEASED" });
//e.Row.Cells[6].Controls.Clear();
//e.Row.Cells[6].Controls.Add(new Literal() { Text = "<del>View</del>" });
//e.Row.Cells[7].Controls.Clear();
//e.Row.Cells[7].Controls.Add(new Literal() { Text = "<del>View</del>" });
}
}
}
}
는 프론트 엔드 코드입니다 .. 내 RowCreated 방법으로하고 있어요 무엇 :
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="FullSearchResults.ascx.cs" Inherits="MyControls.FullSearchResults" %>
<div id="search-results">
<asp:GridView ID="gvResults" runat="server" AutoGenerateColumns="false" DataSourceID="odsProperties"
AllowSorting="true" Width="700px" OnRowCommand="gvResults_RowCommand" OnRowCreated="gvResults_RowCreated">
<HeaderStyle CssClass="gv-header" ForeColor="#ffffff" />
<RowStyle BackColor="White" ForeColor="#333333" />
<AlternatingRowStyle BackColor="#e6e6e6" ForeColor="#333333" />
<Columns>
<asp:BoundField DataField="Plot" HeaderText="Plot" SortExpression="Plot" />
<asp:TemplateField HeaderText="Development" SortExpression="Development">
<ItemTemplate>
<%# Eval("DevelopmentName").ToString() %>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Location" SortExpression="Location">
<ItemTemplate>
<%# Eval("LocationDisplayText").ToString() %>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Type" SortExpression="Type">
<ItemTemplate>
<%# Eval("PropertyTypeName").ToString() %>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Beds" SortExpression="Bedrooms">
<ItemTemplate>
<%# Eval("BedroomsDisplayText").ToString() %>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Price" SortExpression="Price">
<ItemTemplate>
<%# Eval("PriceDisplayText").ToString() %>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Plans">
<ItemTemplate>
<asp:LinkButton ID="btnViewFloorplans" runat="server" CommandName="View" Text="View"
CommandArgument='<%# (int)Eval("Id") %>' CssClass="view-floorplan" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Image">
<ItemTemplate>
<asp:LinkButton ID="btnViewImage" runat="server" CommandName="View" Text="View"
CommandArgument='<%# (int)Eval("Id") %>' CssClass="view-floorplan" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:ObjectDataSource ID="odsProperties" runat="server" TypeName="MyControls.DataAccess"
SelectMethod="GetSearchResultsForAllDevelopments" SortParameterName="_sortExpression">
<SelectParameters>
<asp:QueryStringParameter Name="_county" QueryStringField="loc" Type="Int16" DefaultValue="-1" />
<asp:QueryStringParameter Name="_bedrooms" QueryStringField="rooms" Type="Int16"
DefaultValue="-1" />
<asp:QueryStringParameter Name="_price" QueryStringField="price" Type="Int16" DefaultValue="-1" />
<asp:QueryStringParameter Name="_propertyType" QueryStringField="type" Type="Int16"
DefaultValue="-1" />
</SelectParameters>
</asp:ObjectDataSource>
</div>
'RowCreated'가 매번 트리거됩니다. 그래서 우리에게 몇 가지 코드를 보여줘야합니다. –
클라이언트 측 정렬 기능이 있습니까? 왜냐하면 Tim이 말했듯이, RowCreated는 모든 게시물을 다시 발생시키기 때문입니다. –
하지만 모든 포스트 백이 발생하면 반드시 내 코드가 실행되어야합니다. 현재로서는 보이지 않습니다. – alimac83