嵌套Datagrid复选框事件中的性能问题 [英] Performance issue in Nested Datagrid checkbox event

查看:76
本文介绍了嵌套Datagrid复选框事件中的性能问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个datagrid,里面有一个datagrid.并且在datagrid里面,有多个记录分别带有一个复选框.选中任何复选框后,该复选框前面的链接应该是可见的.



请检查代码ASPX页面代码我有一个datagrid

< asp:DataGrid Width ="722" AutoGenerateColumns ="false" CellSpacing ="0" CellPadding ="0" ID ="dgPln" runat ="server" AllowPaging ="false" AllowSorting ="false" ShowHeader ="false" BorderWidth ="0px" BorderColor ="white"> < asp:BoundColumn Visible ="false" DataField ="pd_id"> < asp:BoundColumn Visible ="false" DataField ="sa_id"> < asp:TemplateColumn> <%----%> <%----%> <%-< asp:ImageButton ID ="imgbtnCrt" runat ="server" ImageUrl ="/images/Add to Selected.gif" border ="0" CommandName ="ADDCRT"/> < asp:ImageButton ID ="imgBtnCmpr" runat =服务器" ImageUrl ="/images/bt-compare.gif" border ="0" CommandName ="COMPR"/> < asp:ImageButton ID ="imgBtnVwAll" runat =服务器" ImageUrl ="/images/View All.gif" border ="0" CommandName ="VWALL"/> <%#Eval("pln_disp")%>决策表<%#Eval("pln_disp")%>决策表< asp:DataGrid AutoGenerateColumns ="true" CellSpacing ="0" CellPadding ="5" ID ="dgPlnDtls" runat ="server" AllowPaging ="false" AllowSorting ="false" HeaderStyle-BackColor =#E4F3C7" HeaderStyle-CssClass ="dg-header-is" ItemStyle-BackColor =#F5F5F5" ItemStyle-CssClass ="dg-item" BorderColor ="LightGray" BorderWidth ="1px"> < asp:TemplateColumn HeaderText =产品名称" HeaderStyle-Horizo​​ntalAlign ="Center"> < div id ="dvLgo" runat =服务器" style ="display:none"> < img id ="imgInsLg" runat =服务器" width ="85" height ="30"/> < asp:标签id ="lblPrdNm" runat =服务器" visible ="false"> < asp:CheckBox ID ="chkCrtLg" runat ="server" visible ="false" OnCheckedChanged ="ChkLgLnkBtn" AutoPostBack ="true"/> < asp:标签id ="spnCmpLg" runat =服务器" visible ="false" ForeColor =#95d831">比较< asp:LinkBut​​ton ID ="lnkCmpLg" runat =服务器" Visible ="false" ForeColor =#eb6907" Font-Bold ="true" OnCommand ="Comp_Logo">单击以进行比较< div id ="dvNLgo" runat ="server" style ="display:none"> < asp:标签id ="lblNPrdNm" runat =服务器" visible ="false"> < asp:CheckBox ID ="chkCrt" runat ="server" visible ="false" OnCheckedChanged ="ChkLnkBtn" AutoPostBack ="true"/> < asp:标签id ="spnCmp" runat =服务器" visible ="false" ForeColor =#95d831">比较< asp:LinkBut​​ton ID ="lnkCmp" runat =服务器" Visible ="false" ForeColor =#eb6907" Font-Bold ="true" OnCommand ="Comp_NoLogo">单击以进行比较<%-< asp:CheckBox ID ="chkCrt" runat ="server"/>-%> < asp:TemplateColumn Visible ="false"> < asp:TableCell ID ="tblCell" runat ="server"> < asp:TemplateColumn ItemStyle-Horizo​​ntalAlign ="Center" ItemStyle-VerticalAlign ="Middle" HeaderText =" Visible ="false"> < asp:LinkBut​​ton ID ="btnBuy" Text =立即购买" runat =服务器" ForeColor =#006600" Font-Bold ="true"/> < asp:BoundColumn DataField ="pd_disp_nm" Visible ="false" ItemStyle-Horizo​​ntalAlign ="Center"> < asp:BoundColumn Visible ="false" DataField ="srno">

我在复选框选中的事件上编写了以下代码

Public Sub ChkLnkBtn(ByVal发送者为对象,ByVal e为System.EventArgs)
Dim chkCrt作为复选框Dim dgPlnDtls作为DataGrid Dim tblCell作为TableCell Dim spnCmp作为标签Dim lnkCmp作为LinkBut​​ton chkCrt = CType(sender,CheckBox)Dim vsAttrId as String()= Split(chkCrt.Attributes("pd_prdId"),"|"如果chkCrt.Checked = True,则dgPln.Items.Count> 0然后对于Me.viCmNt = 0到dgPln.Items.Count-1如果vsAttrId(0)= dgPln.Items(viCmNt).Cells(0).Text&-"&dgPln.Items(viCmNt).Cells(1 ).Text然后dgPlnDtls = Nothing dgPlnDtls = CType(dgPln.Items(viCmNt).Cells(2).FindControl("dgPlnDtls"),DataGrid)如果dgPlnDtls.Items.Count> 0然后对于Me.viCntB = 0到dgPlnDtls.Items.Count-1 tblCell =否tblCell = CType(dgPlnDtls.Items(viCntB).Cells(1).FindControl("tblCell"),TableCell)spnCmp =否spnCmp = CType (dgPlnDtls.Items(viCntB).Cells(0).FindControl("spnCmp"),标签)lnkCmp =否lnkCmp = CType(dgPlnDtls.Items(viCntB).Cells(0).FindControl("lnkCmp"),LinkBut​​ton)如果vsAttrId(1)= tblCell.Text,则spnCmp.Visible = False lnkCmp.Visible = True退出
如果
,则退出以结束 结束子

请为我提供解决方案....

I have a datagrid inside that datagrid one more datagrid is there.and inside that datagrid multiple records are there with one checkbox respectively.After selecting any checkbox the links which are there in front of that checkbox should be visible.



kindly check the code ASPX page code I have a datagrid

<asp:DataGrid Width="722" AutoGenerateColumns="false" CellSpacing="0" CellPadding="0" ID="dgPln" runat="server" AllowPaging="false" AllowSorting="false" ShowHeader="false" BorderWidth="0px" BorderColor="white"> <asp:BoundColumn Visible="false" DataField="pd_id"> <asp:BoundColumn Visible="false" DataField="sa_id"> <asp:TemplateColumn> <%----%> <%----%> <%-- <asp:ImageButton ID="imgbtnCrt" runat="server" ImageUrl="/images/Add to Selected.gif" border="0" CommandName="ADDCRT" /> <asp:ImageButton ID="imgBtnCmpr" runat="server" ImageUrl="/images/bt-compare.gif" border="0" CommandName="COMPR" /> <asp:ImageButton ID="imgBtnVwAll" runat="server" ImageUrl="/images/View All.gif" border="0" CommandName="VWALL" /> <%#Eval("pln_disp")%> Decision Table <%#Eval("pln_disp")%> Decision Table <asp:DataGrid AutoGenerateColumns="true" CellSpacing="0" CellPadding="5" ID="dgPlnDtls" runat="server" AllowPaging="false" AllowSorting="false" HeaderStyle-BackColor="#E4F3C7" HeaderStyle-CssClass="dg-header-is" ItemStyle-BackColor="#F5F5F5" ItemStyle-CssClass="dg-item" BorderColor="LightGray" BorderWidth="1px"> <asp:TemplateColumn HeaderText="Product Name" HeaderStyle-HorizontalAlign="Center"> <div id="dvLgo" runat="server" style="display:none"> <img id="imgInsLg" runat="server" width="85" height="30" /> <asp:Label id="lblPrdNm" runat="server" visible="false"> <asp:CheckBox ID="chkCrtLg" runat="server" visible="false" OnCheckedChanged="ChkLgLnkBtn" AutoPostBack="true" /> <asp:Label id="spnCmpLg" runat="server" visible="false" ForeColor="#95d831">Compare <asp:LinkButton ID="lnkCmpLg" runat="server" Visible="false" ForeColor="#eb6907" Font-Bold="true" OnCommand="Comp_Logo">Click to Compare <div id="dvNLgo" runat="server" style="display:none"> <asp:Label id="lblNPrdNm" runat="server" visible="false"> <asp:CheckBox ID="chkCrt" runat="server" visible="false" OnCheckedChanged="ChkLnkBtn" AutoPostBack="true" /> <asp:Label id="spnCmp" runat="server" visible="false" ForeColor="#95d831">Compare <asp:LinkButton ID="lnkCmp" runat="server" Visible="false" ForeColor="#eb6907" Font-Bold="true" OnCommand="Comp_NoLogo">Click to Compare <%--<asp:CheckBox ID="chkCrt" runat="server" />--%> <asp:TemplateColumn Visible="false"> <asp:TableCell ID="tblCell" runat="server"> <asp:TemplateColumn ItemStyle-HorizontalAlign="Center" ItemStyle-VerticalAlign="Middle" HeaderText="" Visible="false"> <asp:LinkButton ID="btnBuy" Text="Buy Now" runat="server" ForeColor ="#006600" Font-Bold ="true" /> <asp:BoundColumn DataField="pd_disp_nm" Visible="false" ItemStyle-HorizontalAlign=''Center''> <asp:BoundColumn Visible="false" DataField="srno">

I have written following code on checkbox checked event

Public Sub ChkLnkBtn(ByVal sender As Object, ByVal e As System.EventArgs)
Dim chkCrt As CheckBox Dim dgPlnDtls As DataGrid Dim tblCell As TableCell Dim spnCmp As Label Dim lnkCmp As LinkButton chkCrt = CType(sender, CheckBox) Dim vsAttrId As String() = Split(chkCrt.Attributes("pd_prdId"), "|") If chkCrt.Checked = True Then If dgPln.Items.Count > 0 Then For Me.viCmNt = 0 To dgPln.Items.Count - 1 If vsAttrId(0) = dgPln.Items(viCmNt).Cells(0).Text & "-" & dgPln.Items(viCmNt).Cells(1).Text Then dgPlnDtls = Nothing dgPlnDtls = CType(dgPln.Items(viCmNt).Cells(2).FindControl("dgPlnDtls"), DataGrid) If dgPlnDtls.Items.Count > 0 Then For Me.viCntB = 0 To dgPlnDtls.Items.Count - 1 tblCell = Nothing tblCell = CType(dgPlnDtls.Items(viCntB).Cells(1).FindControl("tblCell"), TableCell) spnCmp = Nothing spnCmp = CType(dgPlnDtls.Items(viCntB).Cells(0).FindControl("spnCmp"), Label) lnkCmp = Nothing lnkCmp = CType(dgPlnDtls.Items(viCntB).Cells(0).FindControl("lnkCmp"), LinkButton) If vsAttrId(1) = tblCell.Text Then spnCmp.Visible = False lnkCmp.Visible = True Exit For
Exit For End If
End Sub

Please provide me solution....

推荐答案

您可以发布一些代码吗?

在本地快速运行的代码并不意味着它将在生产服务器上执行相同的操作.相反,如果生产服务器具有相同类型的硬件配置,则总是很慢,因为实时服务器必须向许多其他用户请求服务器,再加上Web服务器上每个应用程序都有一个池,并且每个池都定义了一组您的应用程序可能消耗的资源,例如,您的应用程序可能属于一个池,其中允许100 MB的内存和10%的CPU使用率.

这种情况在本地服务器上是不同的,因为这专用于您的应用程序,并且您始终拥有全部资源.

您不能在单击复选框时放一些JavaScript来启用/禁用超链接吗?
Can you post some code?

Code running fast on your local doesn''t mean it will perform the same on production server. On the contrary it is always slow if you have same type of hardware configuration for production server because the live server has to server request to lot of other users, plus there is a pool for each application on web server and each pool has defined set of resources your application can consume for example your application may fall in a pool where 100 MB of ram and 10% of CPU usage is allowed.

The case is not the same on your local server because that is dedicated to your application and you have full resources all the time available.

Cannot you put some javascript to enable/disable hyperlinks on clicking of checkboxes?


这篇关于嵌套Datagrid复选框事件中的性能问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆