我有三个GridView
,由于某种原因,前三列的第一个重复数据>它不是错误,因为这就是我想要的。
我希望网格在上述两列Client Name
和Branch
. 我遍历我的单元格并将它们设置为空,Databound
如下所示。
protected void gvList_RowDataBound(object sender, GridViewRowEventArgs e)
{
string oldValue = string.Empty;
string newValue = string.Empty;
// for (int count = 0; count < gvList.Rows.Count; count++)
for (int j = 0; j < 2; j++)
{
for (int count = 0; count < gvList.Rows.Count; count++)
{
oldValue = gvList.Rows[count].Cells[j].Text;
if (oldValue == newValue)
{
gvList.Rows[count].Cells[j].Text = string.Empty;
}
newValue = oldValue;
}
}
}
运行后我得到下面的结果。网格做我想做的一行,并省略了继续它的行。我很困惑。请更好的选择将不胜感激。
我的第二个问题是,我还有另一个网格也重复了几行。我应用了相同的方法,Dispose()
其中重复但没有任何变化。我用
gridview.rows[].cells.clear/disposed()`
我的girdview如下。
<asp:GridView ID="gvList" runat="server" AutoGenerateColumns="False" AllowPaging="true" AllowSorting="true" OnSorting="gvList_sorting"
DataKeyNames="contactID" OnPageIndexChanging="gvList_PageIndexChanging" OnRowCancelingEdit="gvList_RowCancelingEdit"
OnRowDeleting="gvList_RowDeleting" OnRowEditing="gvList_RowEditing" OnRowUpdating="gvList_RowUpdating" OnRowDataBound="gvList_RowDataBound"
EnableModelValidation="True" CellPadding="4" ForeColor="#333333" GridLines="None" ShowFooter="True">
<Columns>
<asp:BoundField DataField="cname" HeaderText="Client Name" ReadOnly="true" SortExpression="cname" />
<asp:BoundField DataField="bname" HeaderText="Branch" ReadOnly="true" SortExpression="bname" />
<asp:BoundField DataField="name" HeaderText="Contact " SortExpression="name" />
<asp:BoundField DataField="type" HeaderText="Type " SortExpression="type" ReadOnly="true" />
<asp:BoundField DataField="description" HeaderText="Description " SortExpression="description" ReadOnly="true" />
<asp:CommandField ShowEditButton="true" />
<asp:TemplateField>
<ItemTemplate>
<asp:linkbutton id="ContactlnkDelete" runat="server" text="Delete" causesvalidation="false" commandname="Delete" commandargument="ID">
</asp:linkbutton>
<cc1:modalpopupextender id="lnkDelete_ModalPopupExtender2" runat="server" cancelcontrolid="ButtonDeleteCancel" okcontrolid="ButtonDeleleOkay"
targetcontrolid="ContactlnkDelete" popupcontrolid="DivDeleteConfirmation" backgroundcssclass="ModalPopupBG">
</cc1:modalpopupextender>
<cc1:confirmbuttonextender id="lnkDelete_ConfirmButtonExtender2" runat="server" targetcontrolid="ContactlnkDelete" enabled="True"
displaymodalpopupid="lnkDelete_ModalPopupExtender2">
</cc1:confirmbuttonextender>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#EFF3FB" />
<EditRowStyle BackColor="#2461BF" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
但它也失败了。拜托,我需要你的帮助。