高分求助,ASPxGridView 使用

ilovegym 2011-06-24 12:20:37
ASPxGridView 在使用 DataItemTemplate 点页面任何按钮,会导致数据错乱
情境:
1.ASPxGridView 邦定数据
2.点ASPxGridView的其中有用到DataItemTemplate的例进行排序
3.点页面任何按钮,出现数据错乱(这时并没有触发重新读取数据.)

aspx代码
<dx:ASPxGridView ID="gvLicenseCost" runat="server" Width="100%" KeyFieldName="FUD_LicenseAdminSq"
set AutoGenerateColumns="False" OnBeforeColumnSortingGrouping="gvLicenseCost_BeforeColumnSortingGrouping">
<Styles>
<AlternatingRow Enabled="true" />
<Header CssClass="tr_fixedrow" />
</Styles>
<SettingsText EmptyDataRow="<%$ Resources:Resource,ERPCTL1005000271%>" />
<SettingsPager Mode="ShowAllRecords" />
<SettingsLoadingPanel Mode="Disabled" />

<Columns>
<dx:GridViewDataTextColumn FieldName="LicenseCountry" VisibleIndex="1" CellStyleHorizontalAlign="Left"
HeaderStyle-HorizontalAlign="Center" Caption="<%$ Resources:Resource,ERPFUD1002005031%>"
Width="9%">
<DataItemTemplate> <asp:Label ID="lblLicenseCountry" runat="server" Text='<%# Eval("LicenseCountry") %>'></asp:Label>
</DataItemTemplate>
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="FUD_LicenseAdminNm" VisibleIndex="2" CellStyle-HorizontalAlign="Center"
HeaderStyle-HorizontalAlign="Center" Caption="<%$ Resources:Resource,ERPCOM1002001691 %>"
Width="15%">
<DataItemTemplate> <asp:LinkButton ID="lbtnViewLicenseAdmin" runat="server" Text='<%# Eval("FUD_LicenseAdminNm") %>' OnClientClick="OpenDetail(this);return false;"></asp:LinkButton> <asp:HiddenField ID="hidLicenseAdminSq" runat="server" Value='<%# Eval("FUD_LicenseAdminSq") %>' />
</DataItemTemplate>
</dx:GridViewDataTextColumn>
</Columns>
</dx:ASPxGridView>
...全文
138 点赞 收藏 5
写回复
5 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
ycproc 2011-06-24

<!--search end-->
<dx:ASPxGridView ID="ASPxGridViewCustomerList" DataSourceID="SqlDataSourceCustomerList"
runat="server" OnHtmlDataCellPrepared="ASPxGridViewCustomerList_HtmlDataCellPrepared"
KeyFieldName="KHBH" AutoGenerateColumns="False" ClientIDMode="AutoID" CssFilePath="~/App_Themes/Aqua/{0}/styles.css"
CssPostfix="Aqua" Width="100%">
<Columns>
<dx:GridViewDataHyperLinkColumn Caption="客户名称" FieldName="KHBH" VisibleIndex="0"
ReadOnly="true">
<PropertiesHyperLinkEdit NavigateUrlFormatString="~/Visit/CustomerView.aspx?KHBH={0}"
TextField="XM" Target="_blank">
</PropertiesHyperLinkEdit>
<Settings SortMode="DisplayText" FilterMode="DisplayText" AllowSort="True" />
<CellStyle Wrap="false">
</CellStyle>
</dx:GridViewDataHyperLinkColumn>
<dx:GridViewDataTextColumn Caption="所属公司名称" FieldName="GSMC" VisibleIndex="1">
<Settings AllowSort="True" FilterMode="DisplayText" SortMode="DisplayText" />
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn Caption="固定电话" FieldName="GDDH" VisibleIndex="3">
<Settings AllowSort="True" FilterMode="DisplayText" SortMode="DisplayText" />
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn Caption="移动电话" FieldName="YDDH" VisibleIndex="4">
<Settings AllowSort="True" FilterMode="DisplayText" SortMode="DisplayText" />
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn Caption="传真" FieldName="CZ" VisibleIndex="5">
<Settings AllowAutoFilter="False" AllowSort="True" SortMode="DisplayText" />
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn Caption="客户分类" FieldName="KHFL" VisibleIndex="6">
<Settings AllowAutoFilter="False" AllowSort="True" SortMode="DisplayText" />
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn Caption="编辑人名称" FieldName="YHMC" VisibleIndex="8">
<Settings AllowSort="True" FilterMode="DisplayText" SortMode="DisplayText" />
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn Caption="编辑时间" FieldName="BJSJ" VisibleIndex="9">
<Settings AllowAutoFilter="False" AllowSort="True" FilterMode="DisplayText" SortMode="DisplayText" />
</dx:GridViewDataTextColumn>
<dx:GridViewDataHyperLinkColumn Caption="编辑" FieldName="KHBH" VisibleIndex="10" ReadOnly="True">
<PropertiesHyperLinkEdit NavigateUrlFormatString="~/Visit/CustomerRegister.aspx?KHBH={0}"
Text="编辑" Target="_blank">
</PropertiesHyperLinkEdit>
<Settings SortMode="DisplayText" AllowAutoFilter="False" />
<Settings SortMode="DisplayText" />
<Settings SortMode="DisplayText" />
<CellStyle Wrap="False">
</CellStyle>
</dx:GridViewDataHyperLinkColumn>
<dx:GridViewCommandColumn VisibleIndex="11" Caption="操作">
<DeleteButton Visible="True" Text="删除">
</DeleteButton>
<ClearFilterButton Visible="True">
</ClearFilterButton>
</dx:GridViewCommandColumn>
</Columns>
<SettingsBehavior AllowDragDrop="False" AllowSort="true" />
<SettingsBehavior ConfirmDelete="true" />
<Settings ShowFilterRow="True" />
<SettingsText ConfirmDelete="确定要删除吗?" />
<SettingsPager PageSize="15">
</SettingsPager>
<SettingsLoadingPanel ImagePosition="Top" />
<SettingsLoadingPanel ImagePosition="Top" />
<SettingsLoadingPanel ImagePosition="Top" />
<Images SpriteCssFilePath="~/App_Themes/Aqua/{0}/sprite.css">
<LoadingPanelOnStatusBar Url="~/App_Themes/Aqua/GridView/gvLoadingOnStatusBar.gif">
</LoadingPanelOnStatusBar>
<LoadingPanel Url="~/App_Themes/Aqua/GridView/Loading.gif">
</LoadingPanel>
</Images>
<ImagesEditors>
<StylesEditors>
<CalendarHeader Spacing="1px">
</CalendarHeader>
<ProgressBar Height="25px">
</ProgressBar>
</StylesEditors>
</dx:ASPxGridView>
<asp:UpdateProgress ID="UpdateProgress1" runat="server" DisplayAfter="0">
<ProgressTemplate>
<asp:Image ID="UpdateProgressImage" runat="server" ImageUrl="~/images/loading.gif"
Style="position: absolute; left: 50%; top: 50%;" />
</ProgressTemplate>
</asp:UpdateProgress>
</ContentTemplate>
</asp:UpdatePanel>
<asp:SqlDataSource ID="SqlDataSourceCustomerList" runat="server" ConnectionString="<%$ ConnectionStrings:CMSPMSDBConnectionString %>"
DeleteCommand="PKG_CUSTOMERINFO.P_DELCUSTOMER" DeleteCommandType="StoredProcedure"
ProviderName="<%$ ConnectionStrings:CMSPMSDBConnectionString.ProviderName %>"
SelectCommand="PKG_CUSTOMERINFO.P_QUERYCUSTOMERINFOLIST" SelectCommandType="StoredProcedure"
OnDeleting="SqlDataSourceCustomerList_Deleting" OnSelecting="SqlDataSourceCustomerList_Selecting">
<DeleteParameters>
<asp:Parameter Name="v_khbh" Type="String" />
<asp:Parameter Name="v_czr" Type="String" />
</DeleteParameters>
<SelectParameters>
<asp:Parameter Name="v_yhbh" Type="String" />
<asp:Parameter Name="v_khxm" Type="String" />
<asp:Parameter Name="v_ssgsbh" Type="String" />
<asp:Parameter Name="v_cxlx" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
</div>
<!--mainbox_c end-->
回复
chenhongjun0624 2011-06-24
看看是不是格式写的问题
回复
zmm12 2011-06-24
用法和DataGrid有什么区别吗?

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindData();
}
}

private void BindData()
{
DataTable table = GetDataTable();

this.DataGridList.DataSource =ModelList;
this.DataGridList.DataBind();
}

回复
子夜__ 2011-06-24
参考

注意样式
<Styles>
<Header HorizontalAlign="Center" /> : 标题居中对齐
<AlternatingRow Enabled="true"/> : 交错行效果
<CommandColumn Paddings-Padding="1" /> :
</Styles>

回复
x363961461 2011-06-24

<dxwgv:ASPxGridView ID="gvAdjust" ClientInstanceName="gvAdjust" KeyFieldName="Guid" runat="server" Width="100%" AutoGenerateColumns="False">
<Columns>
<dxwgv:GridViewCommandColumn ShowSelectCheckbox="true" VisibleIndex="0" Visible="false">
<HeaderTemplate>
<input type="checkbox" onclick="gvAdjust.SelectAllRowsOnPage(this.checked);" title="选择/取消选择" style="vertical-align:middle;"></input>
</HeaderTemplate>
<HeaderStyle Paddings-PaddingTop="1" Paddings-PaddingBottom="1" HorizontalAlign="Center">
<Paddings PaddingTop="1px" PaddingBottom="1px"></Paddings>
</HeaderStyle>
</dxwgv:GridViewCommandColumn>
<dxwgv:GridViewDataCheckColumn Caption="审核" FieldName="YS" Width="30px" VisibleIndex="1">
</dxwgv:GridViewDataCheckColumn>
<dxwgv:GridViewDataTextColumn Caption="单据编号" FieldName="DJBH" VisibleIndex="2">
</dxwgv:GridViewDataTextColumn>
<dxwgv:GridViewDataTextColumn Caption="业务日期" FieldName="RQ" VisibleIndex="3">
<PropertiesTextEdit DisplayFormatString="yyyy-MM-dd"></PropertiesTextEdit>
</dxwgv:GridViewDataTextColumn>
<dxwgv:GridViewDataTextColumn Caption="调整类型" FieldName="LXMC" VisibleIndex="4">
</dxwgv:GridViewDataTextColumn>
<dxwgv:GridViewDataTextColumn Caption="仓库" FieldName="CKMC" VisibleIndex="5">
</dxwgv:GridViewDataTextColumn>
<dxwgv:GridViewDataTextColumn Caption="制单人" FieldName="ZDR" VisibleIndex="6"></dxwgv:GridViewDataTextColumn>
<dxwgv:GridViewDataTextColumn Caption="制单日期" FieldName="ZDRQ" VisibleIndex="7">
<PropertiesTextEdit DisplayFormatString="yyyy-MM-dd"></PropertiesTextEdit>
</dxwgv:GridViewDataTextColumn>
</Columns>
<ClientSideEvents RowDblClick="view" />
<Settings ShowFilterRow="false" ShowVerticalScrollBar="True" VerticalScrollableHeight="347"/>
<SettingsBehavior AllowFocusedRow="true" />
<SettingsPager PageSize="50" Visible="False" />
</dxwgv:ASPxGridView>



protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.cboCANGKU.DataSource = new CANGKU().GetList(new QueryCondition() { FieldName = "TY", Comparison = "=", Value = "0" });
this.cboCANGKU.DataBind();
this.cboTZLX.DataSource = new KCTZLX().GetList(new QueryCondition() { FieldName = "IS_TY", Comparison = "=", Value = "0" });
this.cboTZLX.DataBind();
this.cboCANGKU.Items.Insert(0, new DevExpress.Web.ASPxEditors.ListEditItem("", "-1"));
this.cboTZLX.Items.Insert(0, new DevExpress.Web.ASPxEditors.ListEditItem("", "-1"));
this.cboCANGKU.SelectedIndex = 0;
this.cboTZLX.SelectedIndex = 0;
this.cboYS.SelectedIndex = 0;
}
if (!IsPostBack || this.gvAdjust.IsCallback || Common.IsExport)
{
BindData();
}
}

private void BindData()
{
List<QueryCriteria> condition = new List<QueryCriteria>();
if (!string.IsNullOrEmpty(this.deBeginDate.Text))
{
condition.Add(new QueryCriteria() { FieldName = "RQ", Comparison = EnumSqlComparison.LargerEqualThan, Value = this.deBeginDate.Date.ToString("yyyy-MM-dd 00:00:00") });
}
if (!string.IsNullOrEmpty(this.deEndDate.Text))
{
condition.Add(new QueryCriteria() { FieldName = "RQ", Comparison = EnumSqlComparison.LessEqualThan, Value = this.deEndDate.Date.ToString("yyyy-MM-dd 23:59:59") });
}
if (!string.IsNullOrEmpty(this.txtDJBH.Text))
{
condition.Add(new QueryCriteria() { FieldName = "DJBH", Comparison = EnumSqlComparison.Like, Value = this.txtDJBH.Text.Replace("'", "''") });
}
if (!this.cboTZLX.Value.Equals("-1"))
{
condition.Add(new QueryCriteria() { FieldName = "LXMC", Comparison = EnumSqlComparison.Like, Value = this.cboTZLX.Text.Replace("'", "''") });
}
if (!this.cboCANGKU.Value.Equals("-1"))
{
condition.Add(new QueryCriteria() { FieldName = "CKMC", Comparison = EnumSqlComparison.Like, Value = this.cboCANGKU.Text.Replace("'", "''") });
}
if (!this.cboYS.Value.Equals("-1"))
{
condition.Add(new QueryCriteria() { FieldName = "YS", Comparison = EnumSqlComparison.Equal, Value = this.cboYS.Value.ToString() });
}
this.ASPxPager1.ItemCount = new V_CKTZD().GetCount(condition);
this.gvAdjust.DataSource = new V_CKTZD().GetList(condition, this.ASPxPager1.PageIndex + 1).OrderByDescending(p => p.ZDRQ);
this.gvAdjust.DataBind();
}

protected void ASPxPager1_PageIndexChanged(object sender, EventArgs e)
{
BindData();
}

public void Query()
{
if (this.ASPxPager1.PageIndex != 0) this.ASPxPager1.PageIndex = 0;
BindData();
}

回复
相关推荐
发帖
智能路由器
创建于2018-06-15

638

社区成员

智能路由器通常具有独立的操作系统,包括OpenWRT、eCos、VxWorks等,可以由用户自行安装各种应用,实现网络和设备的智能化管理。
申请成为版主
帖子事件
创建了帖子
2011-06-24 12:20
社区公告
暂无公告