Click here to Skip to main content
15,896,207 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
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....
Posted
Updated 30-Nov-11 2:07am
v2
Comments
shek124 30-Nov-11 10:32am    
please use <pre> tag.

1 solution

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?
 
Share this answer
 
Comments
PrachiMhatre 30-Nov-11 4:48am    
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
Ne

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900