如何在ASP.NET C#中添加动态gridview? [英] How to add dynamic gridview in ASP.NET C#?

查看:95
本文介绍了如何在ASP.NET C#中添加动态gridview?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个主网格视图在那两个链接按钮。如果我点击Linkbutton1它应该在另一个gridview.IF中显示数据我点击它上面的linkbutton2应该显示另一个gridview的数据。它就像单个主网格视图的2个childgirdview。任何人都可以通过示例编码帮助我如何做到这一点?







提前致谢!!!



我的尝试:



我的设计页面在这里:



Hi,
I have a master gridview In that two link buttons. If I click on Linkbutton1 it should display data in another gridview.IF I click on linkbutton2 in it should display data another gridview. It's just like 2 childgirdview for single master gridview.Can anyone help me to How to do this through example coding?



Thanks in advance!!!

What I have tried:

My Design Page Here:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="LoanAccountDetails.aspx.cs"
    Inherits="LoanAccountDetails" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Banksoft Internet Banking</title>
    <link href="Css/Banksoftstyles.css" rel="stylesheet" type="text/css" />

    <script src="js/BanksoftScript.js" type="text/javascript"></script>

    <link href="Css/style.css" rel="stylesheet" type="text/css" />

    <script type="text/javascript">
        function preventBack() { window.history.forward(); }
        setTimeout("preventBack()", 0);
        window.onunload = function() { null };
    </script>
  <%--Added by shruthi N--%> 
   <script type="text/javascript">
       function showNestedGridView(obj) {
           var NestedGridView = document.getElementById(obj);
           var imageID = document.getElementById('image' + obj);

           if (NestedGridView.style.display == "none") {
               NestedGridView.style.display = "inline";
               // imageID.src = "img/minus.png";
           }
           else {
               NestedGridView.style.display = "none";
               //imageID.src = "img/plus.png";
           }
       }
</script>
    <%--Added by janardhan, the following functions disable the View Source and Ctrl+U--%>

    <script type="text/javascript" language="javascript">
        $(function() { $(this).bind("contextmenu", function(e) { e.preventDefault(); }); }); 
    </script>

    <script type="text/javascript" language="javascript">
        document.onkeydown = function(e) {
            if (e.ctrlKey &&
            (e.keyCode === 85)) {
                return false;
            }
        };
    </script>

   <%-- <script type="text/javascript" language="javascript">
        function fnDispJointAcntDets() {
            var settings = 'width=640,height=400,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=No,resizable=No,top=100%,left=350%,position: fixed';            
            url = 'Help/JointAcntDetails.aspx';
            popup = window.open(url, '', settings, target = '_blank');
            popup.focus();
        }
        function fnDispSuretyDets() {
            var settings = 'width=640,height=400,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=No,top=100%,left=350%,position: fixed';
            url = 'Help/SuretyorGuarantor.aspx';
            popup = window.open(url, '', settings, target = '_blank');
            popup.focus();
        }
    </script>
--%>
</head>
<body style="overflow-x:hidden;overflow-y:hidden;">
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>       
            <%--<div>--%>
           <div class="main">             
                <%--<div class="box">--%>
                    <h5>
                        LOAN ACCOUNT DETAILS</h5>
                    <center>
                        <br />
                        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"  DataKeyNames="AccountNumber"
                            OnRowCommand="GridView1_RowCommand" 
                            onselectedindexchanged="GridView1_SelectedIndexChanged" 
                            onrowdatabound="GridView1_RowDataBound">
                            <Columns>
                                <asp:TemplateField HeaderText="ACCOUNT NUMBER">
                                    <ItemTemplate>
                                        <asp:LinkButton Style="text-decoration: underline;" ID="Linkbtnacno" runat="server"
                                            EnableTheming="True" Text='<%# Eval("AccountNumber") %>' CommandName="SelectAcNo"></asp:LinkButton>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                 <asp:TemplateField HeaderText="SCHEME NAME">
                                    <ItemTemplate>
                                        <asp:Label ID="lblSchemeName" Style="text-align: justify;" runat="server" Text='<%# Eval("SchemeName") %>'></asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="DATE OF ACCOUNT OPEN">
                                    <ItemTemplate>
                                        <asp:Label ID="lblAcntOpen" Style="text-align: justify;" runat="server" Text='<%# Eval("DateOfActOpening") %>'></asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="ACCOUNT TYPE">
                                    <ItemTemplate>
                                        <asp:Label ID="lblAcntType" Style="text-align: justify;" runat="server" Text='<%# Eval("AccountType") %>'></asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="JOINT HOLDER">
                                    <ItemTemplate>
                                        <%--<asp:LinkButton ID="lbtnJointAcntDetsc" runat="server" Style="display: block; text-align: center;
                                            text-decoration: underline" EnableTheming="True" CommandName="CmdJointAcntDets">Click here</asp:LinkButton>--%>                                            
                                              
                                            <%--  <a href="javascript:showNestedGridView('accountNumber-<%# Eval("AccountNumber") %>');">
                                    <img id="imageaccountNumber-<%# Eval("AccountNumber") %>" text="ClickHere"
                                    alt="ClickHere" border="0"/>--%>
                                              <asp:LinkButton ID="lbtnJointAcntDetsc" runat="server" Style="display: block; text-align: center;
                                        text-decoration: underline" EnableTheming="True" CommandName="CmdJointAcntDets">Click here</asp:LinkButton>
                                        <%--<asp:Label ID="lblJntHolder" Style="text-align: left;" runat="server" Text='<%# Eval("JointHolderName") %>'></asp:Label>--%>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="SURETY DETAILS">
                                    <ItemTemplate>
                                        <asp:LinkButton ID="lbtnNomineeDets" runat="server" Style="display: block; text-align: center;
                                            text-decoration: underline" EnableTheming="True" CommandName="CmdSuretyDets">Click here</asp:LinkButton>
                                        <%--<asp:Label ID="lblNomDetails" Style="text-align: left;" runat="server" Text='<%# Eval("NomineeDetails") %>'></asp:Label>--%>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="DATE OF EXPAIRY">
                                    <ItemTemplate>
                                        <asp:Label ID="lblDtofMaturity" Style="text-align: left;" runat="server" Text='<%# Eval("ExpairyDate") %>'></asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="ROI">
                                    <ItemTemplate>
                                        <asp:Label ID="lblROI" Style="text-align: center;" runat="server" Text='<%# Eval("RateOfInterest") %>'></asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Sanctioned Amount">
                                    <ItemTemplate>
                                        <asp:Label ID="lblDepAmount" Style="text-align: left;" runat="server" Text='<%# Eval("SanctionAmount") %>'></asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Closing Balance">
                                    <ItemTemplate>
                                        <asp:LinkButton ID="lbtnforBlnc" runat="server" Style="display: block; text-align: right;padding:0px;width:80px;
                                            text-decoration: underline" EnableTheming="True" CommandName="ClickforBlnc">Click Here for balance</asp:LinkButton>
                                        <asp:LinkButton ID="lbtnClosing" runat="server" Style="display: block; text-align: right;
                                            text-decoration: underline" EnableTheming="True" Text='<%# Eval("ClosingBalance") %>'
                                            CommandName="SelectClosingBal" Visible="false"></asp:LinkButton>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <%--<asp:TemplateField HeaderText="CLOSING BALANCE">
                            <ItemTemplate>
                                <asp:LinkButton ID="lbtnforBlnc" runat="server" Style="display: block; text-align: right;
                                    text-decoration: underline" EnableTheming="True" CommandName="ClickforBlnc">Click Here for balance</asp:LinkButton>
                                <asp:LinkButton ID="lbtnClosing" runat="server" Style="display: block; text-align: right;
                                    text-decoration: underline" EnableTheming="True" Text='<%# Eval("ClosingBalance") %>'
                                    CommandName="SelectClosingBal" Visible="false"></asp:LinkButton>
                            </ItemTemplate>
                        </asp:TemplateField>--%>
                         <asp:TemplateField>
                            <ItemTemplate>
                                <tr>
                                    <td colspan="100%">
                                        <%--<div id='<%# Eval("AccountNumber")%>' style="display:none">--%>
                                        <div id="accountNumber-<%# Eval("AccountNumber") %>" 
                                            style="display:none;position:relative;left:25px;" >
                                        <%--<div ID="NestedDiv" runat="server">--%>
                            <%--<asp:TemplateField HeaderText="CLOSING BALANCE">
                            <ItemTemplate>
                                <asp:LinkButton ID="lbtnforBlnc" runat="server" Style="display: block; text-align: right;
                                    text-decoration: underline" EnableTheming="True" CommandName="ClickforBlnc">Click Here for balance</asp:LinkButton>
                                <asp:LinkButton ID="lbtnClosing" runat="server" Style="display: block; text-align: right;
                                    text-decoration: underline" EnableTheming="True" Text='<%# Eval("ClosingBalance") %>'
                                    CommandName="SelectClosingBal" Visible="false"></asp:LinkButton>
                            </ItemTemplate>
                        </asp:TemplateField>--%>
                        <asp:GridView ID="GridView2" runat="server"  DataKeyNames="JointCustCode" AutoGenerateColumns="False"
                            Width="80%" style="overflow-y:none;" 
                            onselectedindexchanged="GridView1_SelectedIndexChanged">
                            <Columns>
                                <asp:TemplateField HeaderText="Joint Customer Code">
                                    <ItemTemplate>
                                        <asp:Label ID="lblAcntOpen" Style="text-align: justify;" runat="server" 
                                            Text='<%# Eval("JointCustCode") %>'></asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Desgnation Of Joint Operator">
                                    <ItemTemplate>
                                        <asp:Label ID="lblAcntType" Style="text-align: justify;" runat="server" 
                                            Text='<%# Eval("DesgnOfJointOper") %>'></asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Relation With Account Holder">
                                    <ItemTemplate>
                                        <asp:Label ID="lblDtofMaturity" Style="text-align: left;" runat="server" 
                                            Text='<%# Eval("RelationWithAccHold") %>'></asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>
                            </Columns>
                        </asp:GridView>
                        </div>
                            </td>
                            </tr>
                            
                                   <tr>
                                    <td colspan="100%">
                                        <%--<div id='<%# Eval("AccountNumber")%>' style="display:none">--%>
                                        <div id="accountNumber1" 
                                            style="display:none;position:relative;left:25px;" >
                        <asp:GridView ID="GridView3" runat="server" DataKeyNames="SurityCustCode" AutoGenerateColumns="False" Width="80%">
                            <Columns>
                                <asp:TemplateField HeaderText="Surety Customer Code">
                                    <ItemTemplate>
                                        <asp:Label ID="lblAcntOpen" Style="text-align: justify;" runat="server" Text='<%# Eval("SurityCustCode") %>'></asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Surety Guarantor">
                                    <ItemTemplate>
                                        <asp:Label ID="lblAcntType" Style="text-align: justify;" runat="server" Text='<%# Eval("SurityGuarantor") %>'></asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Description">
                                    <ItemTemplate>
                                        <asp:Label ID="lblDtofMaturity" Style="text-align: left;" runat="server" Text='<%# Eval("Description") %>'></asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>
                            </Columns>
                        </asp:GridView>
                           </div>
                            </td>
                            </tr>
                            </ItemTemplate>
                        </asp:TemplateField>
                            </Columns>
                        </asp:GridView>
                        <br />
                        <asp:LinkButton ID="lnkNoAcntstoDisp" runat="server" Style="color: Red;font-size:large;font-family:Times New Roman"  Text="Sorry, You have no Loan Accounts"></asp:LinkButton>
                    </center>
                <%--</div>--%>
                <div>
                    <center>
                        <asp:Label ID="lblerrormsg" Style="color: Red" runat="server"></asp:Label>
                        <input id="hdnAcntNo" type="hidden" runat="server" />
                    </center>
                </div>
               </div>
            <%--</div>--%>
        </ContentTemplate>
    </asp:UpdatePanel>
    </form>
</body>
</html>









我的代码在asp.net cs后面这里:





公共部分类LoanAccountDetails:System.Web.UI.Page

{

Bclass objb = null;

private ArrayList ArrayParamList = null;



protected void Page_Load(object发件人,EventArgs e)

{

if(!this.IsPostBack)

{



尝试

{

//由janardhan添加以限制用户在地址栏中复制并粘贴网址

string strPreviousPage =;

if(Request.UrlReferrer!= null)

{

strPreviousPage = Request.UrlReferrer.Segments [Request.UrlReferrer。 Segments.Length - 1];

}

if(strPreviousPage ==)

{

Response.Redirect(〜/ ErrorPages / RestrictURLAccess.aspx);

}

//在此结束by janardhan



if(!string.IsNullOrEmpty(SessionHandler.ConnString))

{

// DataTable dt = new DataTable();

// dt = SessionHandler.dsCustomerDetails.Tables [0] .Clone(); / *克隆方法复制表模式* /

// foreach(SessionRandler.dsCustomerDetails.Tables [0] .Rows中的DataRow drw)

// {

// if(Convert.ToString(drw [Categorycode])==LON)

// {

// dt.ImportRow (drw);

//}

//}

//GridView1.DataSource = dt;

//GridView1.DataBind();

//// SetPageDesign();



string AcNo = SessionHandler.RegAccountNumber;

DataSet ds = new DataSet();

objb = new Bclass();

ArrayParamList = new ArrayList();

ArrayParamList.Add(AcNo.Trim());

ArrayParamList.Add(GetCustL oanAcntDetails);

ds = objb.GetAccountInformation(ArrayParamList);

if(ds!= null&& ds.Tables.Count> 0&& ds.Tables [0] .Rows.Count> 0)

{

GridView1.DataSource = ds.Tables [0];

GridView1.DataBind();



GridView1.Visible = true;

lnkNoAcntstoDisp.Visible = false;

}

else

{

GridView1.Visible = false;

lnkNoAcntstoDisp.Visible = true;

}





}

}

catch(例外情况)

{

lblerrormsg.Text = ex.Message;

lblerrormsg.ForeColor = Color.Red;

}

}

}



protected void SetPageDesign()

{



/ *来自CodeBehind的CssStyle背景颜色* /

/ * Step1:将ID和runat =Server设置为body标签,以便它可以参考代码背后

步骤2:接下来,在代码隐藏上为此body标签添加一个CSS属性,例如* /

if(SessionHandler.BankCode.Equals( BNK00062)/ * BNK00062-Taqwa Credit Cooperative Society Ltd * /

{



}

否则if(SessionHandler.BankCode.Equals(BNK00015))/ * BNK00015-Manvi Pattana Sa Bank Ni * /

{

/ * MPSS * /



}

else if(SessionHandler.BankCode.Equals(BNK00019))/ * BNK00019-SRI VASAVAMBA CO-OPERATIVE BANK LTD * /

{

/ * SVCBHNP * /



}

else if(SessionHandler) .BankCode.Equals(BNK00009))/ * BNK00009-会计师事务所办公室员工合作e Bank Limited * /

{

/ * AGS * /





}

else if(SessionHandler.BankCode.Equals(BNK00045))/ * BNK00045-RESERVE BANK EMPLOYEES CO-OPERATIVE BANK LTD。* /

{

//mybody.Attributes.CssStyle.Add(\"background,linear-gradient(red,yello););

/ * RBE * /



}

else if(SessionHandler.BankCode.Equals(BNK00022) ))/ * BNK00022-Shri Shivayogi Murughendra Swami Urban Co-Op Bank Ltd. * /

{

/ * SSMS * /





}

else if(SessionHandler.BankCode.Equals(BNK00041))/ * BNK00041-Guru raghavendra * /

{



}

else

{

// pagebody.Attributes.CssStyle.Add(background,linear-gradient(#00339a,Gray););



}

}



protected void GridView1_RowCommand(object sender,GridViewCommandEventArgs e)

{

try

{



GridViewRow gvr =(GridViewRow)(((LinkBut​​ton)e.CommandSource).NamingContainer);

int rowIndex = gvr.RowIndex;

LinkBut​​ton HyperAcNo =(LinkBut​​ton)GridView1.Rows [rowIndex] .Cells [0] .FindControl(Linkbtnacno);

Cache [tmpAcntNum] = HyperAcNo.Text。修剪();



if(e.CommandName ==SelectAcNo)

{

回应。重定向(AccountInformation.aspx,true);

}

else if(e.CommandName ==SelectClosingBal)

{

Response.Redirect(ClosingBalance.aspx,true);

}

else if(e.CommandName ==ClickforBlnc)/ *选项显示关闭余额点击Linkbutton * /

{

GridViewRow row =(GridViewRow)(((LinkBut​​ton)e.CommandSource).NamingContainer);

int rIndex = row.RowIndex;

GridView1.Rows [rIndex] .Cells [GridView1.Rows [rIndex] .Cells.Count - 1] .FindControl( lbtnforBlnc)。Visible = false;

GridView1.Rows [rIndex] .Cells [GridView1.Rows [rIndex] .Cells.Count - 1] .FindControl(lbtnClosing)。Visible = true;

}

else if(e.CommandName ==CmdJointAcntDets)

{

// ScriptManager。 RegisterStartupScript(UpdatePanel1,typeof(Page),OnClientClicking,fnDispJointAcntDets(+ hdnAcntNo.Value +);,true);

ScriptManager.RegisterStartupScript(UpdatePanel1,typeof(Page), OnClient点击,fnDispJointAcntDets();,true);

}

else if(e.CommandName ==CmdSuretyDets)

{

//ScriptManager.RegisterStartupScript(UpdatePanel1,typeof(Page),OnClientClicking,fnDispSuretyDets(+ hdnAcntNo.Value +);,true);

ScriptManager.RegisterStartupScript(UpdatePanel1,typeof(Page),OnClientClicking,fnDi spSuretyDets();,true);

}

}

catch(exception ex)

{

lblerrormsg.Text = ex.Message;

lblerrormsg.ForeColor = Color.Red;

}

}

protected void GridView1_SelectedIndexChanged(object sender,EventArgs e)



{



}







protected void GridView1_RowDataBound(object sender,GridViewRowEventArgs e)

{

//图片btnAlert =(图片)e.Row.FindControl(lnkDisplayPopUp_Click);







if(e.Row.RowType == DataControlRowType.DataRow)

{



/ / string ass = e.Row.Cells [4] .Text;



// TableCell statusCell = e.Row.Cells [4];

// if(statusCell.Text ==)

// {

// // if(e.Row.Cells [4] .Text.Contains())

// {$ / $


// LinkBut​​ton lb = e.Row.FindControl(Linkbtnacno)作为LinkBut​​ton;

//ScriptManager.GetCurrent(this ).RegisterPostBackControl(lb);

// string tmpAcntNum = GridView1.DataKeys [e.Row.RowIndex] .Value.ToString();

// GridView gv2 = e.Row.FindControl(GridView2)作为GridView;



string tmpAcntNum = GridView1.DataKeys [e.Row.RowIndex] .Value.ToString();

尝试

{



#region评论

if(!string.IsNullOrEmpty (Convert.ToString(tmpAcntNum)))

{

GridView gv2 =(GridView)e.Row.FindControl(GridView2);

DataSet ds = new DataSet();

objb = new Bclass();

ArrayList ArrayParamList = new ArrayList();

ArrayParamList.Add(tmpAcntNum。修剪());

ArrayParamList.Add(GetCustJointAcntDetails);

ds = objb.GetAccountInformation(ArrayParamList);



if(ds!= null&& ds.Tables.Count> 0&& ds.Tables [0] .Rows.Count> 0)

{

gv2.DataSource = ds.Tables [0];

gv2.DataBind();



}

其他

{

gv2.Visible = true;





}

}

#endregion

}

catch(例外情况)

{

lblerrormsg.Text = ex.Message;

lblerrormsg.ForeColor = Color.Red;

lblerrormsg.Visible = true;

}

终于

{

缓存。删除(AcntNum);

}


}

}





}





My Code Behind asp.net c.s here:


public partial class LoanAccountDetails : System.Web.UI.Page
{
Bclass objb = null;
private ArrayList ArrayParamList = null;

protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{

try
{
//Added by janardhan to restrict the user to copy and paste the url in Address Bar
string strPreviousPage = "";
if (Request.UrlReferrer != null)
{
strPreviousPage = Request.UrlReferrer.Segments[Request.UrlReferrer.Segments.Length - 1];
}
if (strPreviousPage == "")
{
Response.Redirect("~/ErrorPages/RestrictURLAccess.aspx");
}
//Ends here by janardhan

if (!string.IsNullOrEmpty(SessionHandler.ConnString))
{
//DataTable dt = new DataTable();
//dt = SessionHandler.dsCustomerDetails.Tables[0].Clone(); /*Clone method copies the table schema*/
//foreach (DataRow drw in SessionHandler.dsCustomerDetails.Tables[0].Rows)
//{
// if (Convert.ToString(drw["Categorycode"]) == "LON")
// {
// dt.ImportRow(drw);
// }
//}
//GridView1.DataSource = dt;
//GridView1.DataBind();
////SetPageDesign();

string AcNo = SessionHandler.RegAccountNumber;
DataSet ds = new DataSet();
objb = new Bclass();
ArrayParamList = new ArrayList();
ArrayParamList.Add(AcNo.Trim());
ArrayParamList.Add("GetCustLoanAcntDetails");
ds = objb.GetAccountInformation(ArrayParamList);
if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
{
GridView1.DataSource = ds.Tables[0];
GridView1.DataBind();

GridView1.Visible = true;
lnkNoAcntstoDisp.Visible = false;
}
else
{
GridView1.Visible = false;
lnkNoAcntstoDisp.Visible = true;
}


}
}
catch (Exception ex)
{
lblerrormsg.Text = ex.Message;
lblerrormsg.ForeColor = Color.Red;
}
}
}

protected void SetPageDesign()
{

/*CssStyle background color from CodeBehind*/
/*Step1: set ID and runat="Server" to the body tag so that it can be referenced to the Code Behind
Step2: Next, to add a CSS property to this body tag on codebehind, e.g.*/
if (SessionHandler.BankCode.Equals("BNK00062")) /*BNK00062-Taqwa Credit Cooperative Society Ltd*/
{

}
else if (SessionHandler.BankCode.Equals("BNK00015")) /*BNK00015-Manvi Pattana Sa Bank Ni*/
{
/*MPSS*/

}
else if (SessionHandler.BankCode.Equals("BNK00019")) /*BNK00019-SRI VASAVAMBA CO-OPERATIVE BANK LTD*/
{
/*SVCBHNP*/

}
else if (SessionHandler.BankCode.Equals("BNK00009")) /*BNK00009-The Accountant Generals Office Employees Co-operative Bank Limited*/
{
/*AGS*/


}
else if (SessionHandler.BankCode.Equals("BNK00045")) /*BNK00045-RESERVE BANK EMPLOYEES CO-OPERATIVE BANK LTD.*/
{
//mybody.Attributes.CssStyle.Add("background", "linear-gradient(red, yello);");
/*RBE*/

}
else if (SessionHandler.BankCode.Equals("BNK00022")) /*BNK00022-Shri Shivayogi Murughendra Swami Urban Co- Op Bank Ltd.*/
{
/*SSMS*/


}
else if (SessionHandler.BankCode.Equals("BNK00041")) /*BNK00041-Guru raghavendra*/
{

}
else
{
// pagebody.Attributes.CssStyle.Add("background", "linear-gradient(#00339a, Gray);");

}
}

protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
try
{

GridViewRow gvr = (GridViewRow)(((LinkButton)e.CommandSource).NamingContainer);
int rowIndex = gvr.RowIndex;
LinkButton HyperAcNo = (LinkButton)GridView1.Rows[rowIndex].Cells[0].FindControl("Linkbtnacno");
Cache["tmpAcntNum"] = HyperAcNo.Text.Trim();

if (e.CommandName == "SelectAcNo")
{
Response.Redirect("AccountInformation.aspx", true);
}
else if (e.CommandName == "SelectClosingBal")
{
Response.Redirect("ClosingBalance.aspx", true);
}
else if (e.CommandName == "ClickforBlnc") /*Option to show the closing balance onclick of Linkbutton*/
{
GridViewRow row = (GridViewRow)(((LinkButton)e.CommandSource).NamingContainer);
int rIndex = row.RowIndex;
GridView1.Rows[rIndex].Cells[GridView1.Rows[rIndex].Cells.Count - 1].FindControl("lbtnforBlnc").Visible = false;
GridView1.Rows[rIndex].Cells[GridView1.Rows[rIndex].Cells.Count - 1].FindControl("lbtnClosing").Visible = true;
}
else if (e.CommandName == "CmdJointAcntDets")
{
//ScriptManager.RegisterStartupScript(UpdatePanel1, typeof(Page), "OnClientClicking", "fnDispJointAcntDets(" + hdnAcntNo.Value + ");", true);
ScriptManager.RegisterStartupScript(UpdatePanel1, typeof(Page), "OnClientClicking", "fnDispJointAcntDets();", true);
}
else if (e.CommandName == "CmdSuretyDets")
{
//ScriptManager.RegisterStartupScript(UpdatePanel1, typeof(Page), "OnClientClicking", "fnDispSuretyDets(" + hdnAcntNo.Value + ");", true);
ScriptManager.RegisterStartupScript(UpdatePanel1, typeof(Page), "OnClientClicking", "fnDispSuretyDets();", true);
}
}
catch (Exception ex)
{
lblerrormsg.Text = ex.Message;
lblerrormsg.ForeColor = Color.Red;
}
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)

{

}



protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
//Image btnAlert = (Image)e.Row.FindControl("lnkDisplayPopUp_Click");



if (e.Row.RowType == DataControlRowType.DataRow)
{

//string ass = e.Row.Cells[4].Text;

//TableCell statusCell = e.Row.Cells[4];
//if (statusCell.Text == "")
//{
// //if (e.Row.Cells[4].Text.Contains(""))
//{

//LinkButton lb = e.Row.FindControl("Linkbtnacno") as LinkButton;
//ScriptManager.GetCurrent(this).RegisterPostBackControl(lb);
//string tmpAcntNum = GridView1.DataKeys[e.Row.RowIndex].Value.ToString();
//GridView gv2 = e.Row.FindControl("GridView2") as GridView;

string tmpAcntNum = GridView1.DataKeys[e.Row.RowIndex].Value.ToString();
try
{

#region Commented
if (!string.IsNullOrEmpty(Convert.ToString("tmpAcntNum")))
{
GridView gv2 = (GridView)e.Row.FindControl("GridView2");
DataSet ds = new DataSet();
objb = new Bclass();
ArrayList ArrayParamList = new ArrayList();
ArrayParamList.Add(tmpAcntNum.Trim());
ArrayParamList.Add("GetCustJointAcntDetails");
ds = objb.GetAccountInformation(ArrayParamList);

if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
{
gv2.DataSource = ds.Tables[0];
gv2.DataBind();

}
else
{
gv2.Visible = true;


}
}
#endregion
}
catch (Exception ex)
{
lblerrormsg.Text = ex.Message;
lblerrormsg.ForeColor = Color.Red;
lblerrormsg.Visible = true;
}
finally
{
Cache.Remove("AcntNum");
}

}
}


}

推荐答案

(function(){
(function() {


(this).bind(contextmenu,function(e){e。的preventDefault(); }); });
< / script>

< script type =text / javascriptlanguage =javascript>
document.onkeydown = function(e){
if(e.ctrlKey&&
(e.keyCode === 85)){
return false;
}
};
< / script>

<% - < script type =text / javascriptlanguage =javascript>
函数fnDispJointAcntDets(){
var settings ='width = 640,height = 400,toolbar = no,location = no,directories = no,status = no,menubar = no,scrollbars = No,resizable =不,顶部= 100%,左边= 350%,位置:固定';
url ='Help / JointAcntDetails.aspx';
popup = window.open(url,'',settings,target ='_ blank');
popup.focus();
}
函数fnDispSuretyDets(){
var settings ='width = 640,height = 400,toolbar = no,location = no,directories = no,status = no,menubar = no, scrollbars = yes,resizable = No,top = 100%,left = 350%,position:fixed';
url ='Help / SuretyorGuarantor.aspx';
popup = window.open(url,'',settings,target ='_ blank');
popup.focus();
}
< / script>
- %>
< / head>
< body style =overflow-x:hidden; overflow-y:hidden;>
< form id =form1runat =server>
< asp:ScriptManager ID =ScriptManager1runat =server>
< / asp:ScriptManager>
< asp:UpdatePanel ID =UpdatePanel1runat =server>
< ContentTemplate>
<% - < div> - %>
< div class =main>
<% - < div class =box> - %>
< h5>
贷款帐户详情< / h5>
< center>
< br />
< asp:GridView ID =GridView1runat =serverAutoGenerateColumns =FalseDataKeyNames =AccountNumber
OnRowCommand =GridView1_RowCommand
onselectedindexchanged =GridView1_SelectedIndexChanged
onrowdatabound =GridView1_RowDataBound>
< Columns>
< asp:TemplateField HeaderText =ACCOUNT NUMBER>
< ItemTemplate>
< asp:LinkBut​​ton Style =text-decoration:underline; ID =Linkbtnacnorunat =server
EnableTheming =TrueText ='<%#Eval(AccountNumber)%>'CommandName =SelectAcNo>< / asp:LinkBut​​ton>
< / ItemTemplate>
< / asp:TemplateField>
< asp:TemplateField HeaderText =SCHEME NAME>
< ItemTemplate>
< asp:Label ID =lblSchemeNameStyle =text-align:justify; runat =serverText ='<%#Eval(SchemeName)%>'>< / asp:Label>
< / ItemTemplate>
< / asp:TemplateField>
< asp:TemplateField HeaderText =账户开户日期>
< ItemTemplate>
< asp:Label ID =lblAcntOpenStyle =text-align:justify; runat =serverText ='<%#Eval(DateOfActOpening)%>'>< / asp:Label>
< / ItemTemplate>
< / asp:TemplateField>
< asp:TemplateField HeaderText =ACCOUNT TYPE>
< ItemTemplate>
< asp:Label ID =lblAcntTypeStyle =text-align:justify; runat =serverText ='<%#Eval(AccountType)%>'>< / asp:Label>
< / ItemTemplate>
< / asp:TemplateField>
< asp:TemplateField HeaderText =JOINT HOLDER>
< ItemTemplate>
<% - < asp:LinkBut​​ton ID =lbtnJointAcntDetscrunat =serverStyle =display:block; text-align:center;
text-decoration:underlineEnableTheming = TrueCommandName =CmdJointAcntDets>点击此处< / asp:LinkBut​​ton> - %>

<% - < a href =javascript:showNestedGridView('accountNumber-<%#Eval(AccountNumber)%>');>
< img id =imageaccountNumber-<%#Eval(AccountNumber)%> text =ClickHere
alt =ClickHereborder =0/> - %>
< asp:LinkBut​​ton ID =lbtnJointAcntDetscrunat =serverStyle =display:block; text-align:center;
text-decoration:underlineEnableTheming =TrueCommandName = CmdJointAcntDets>点击此处< / asp:LinkBut​​ton>
<% - < asp:Label ID =lblJntHolderStyle =text-align:left; runat =serverText ='<%#Eval(JointHolderName)%>'>< / asp:Label> - %>
< / ItemTemplate>
< / asp:TemplateField>
< asp:TemplateField HeaderText =SURETY DETAILS>
< ItemTemplate>
<asp:LinkButton ID=\"lbtnNomineeDets\" runat=\"server\" Style=\"display: block; text-align: center;
text-decoration: underline\" EnableTheming=\"True\" CommandName=\"CmdSuretyDets\">Click here</asp:LinkButton>
<%--<asp:Label ID=\"lblNomDetails\" Style=\"text-align: left;\" runat=\"server\" Text=’<%# Eval(\"NomineeDetails\") %>’></asp:Label>--%>
< / ItemTemplate>
< / asp:TemplateField>
<asp:TemplateField HeaderText=\"DATE OF EXPAIRY\">
< ItemTemplate>
<asp:Label ID=\"lblDtofMaturity\" Style=\"text-align: left;\" runat=\"server\" Text=’<%# Eval(\"ExpairyDate\") %>’></asp:Label>
< / ItemTemplate>
< / asp:TemplateField>
<asp:TemplateField HeaderText=\"ROI\">
< ItemTemplate>
<asp:Label ID=\"lblROI\" Style=\"text-align: center;\" runat=\"server\" Text=’<%# Eval(\"RateOfInterest\") %>’></asp:Label>
< / ItemTemplate>
< / asp:TemplateField>
<asp:TemplateField HeaderText=\"Sanctioned Amount\">
< ItemTemplate>
<asp:Label ID=\"lblDepAmount\" Style=\"text-align: left;\" runat=\"server\" Text=’<%# Eval(\"SanctionAmount\") %>’></asp:Label>
< / ItemTemplate>
< / asp:TemplateField>
<asp:TemplateField HeaderText=\"Closing Balance\">
< ItemTemplate>
<asp:LinkButton ID=\"lbtnforBlnc\" runat=\"server\" Style=\"display: block; text-align: right;padding:0px;width:80px;
text-decoration: underline\" EnableTheming=\"True\" CommandName=\"ClickforBlnc\">Click Here for balance</asp:LinkButton>
<asp:LinkButton ID=\"lbtnClosing\" runat=\"server\" Style=\"display: block; text-align: right;
text-decoration: underline\" EnableTheming=\"True\" Text=’<%# Eval(\"ClosingBalance\") %>’
CommandName=\"SelectClosingBal\" Visible=\"false\"></asp:LinkButton>
< / ItemTemplate>
< / asp:TemplateField>
<%--<asp:TemplateField HeaderText=\"CLOSING BALANCE\">
< ItemTemplate>
<asp:LinkButton ID=\"lbtnforBlnc\" runat=\"server\" Style=\"display: block; text-align: right;
text-decoration: underline\" EnableTheming=\"True\" CommandName=\"ClickforBlnc\">Click Here for balance</asp:LinkButton>
<asp:LinkButton ID=\"lbtnClosing\" runat=\"server\" Style=\"display: block; text-align: right;
text-decoration: underline\" EnableTheming=\"True\" Text=’<%# Eval(\"ClosingBalance\") %>’
CommandName=\"SelectClosingBal\" Visible=\"false\"></asp:LinkButton>
< / ItemTemplate>
</asp:TemplateField>--%>
<asp:TemplateField>
< ItemTemplate>
< tr>
<td colspan=\"100%\">
<%--<div id=’<%# Eval(\"AccountNumber\")%>’ style=\"display:none\">--%>
<div id=\"accountNumber-<%# Eval(\"AccountNumber\") %>\"
style=\"display:none;position:relative;left:25px;\" >
<%--<div ID=\"NestedDiv\" runat=\"server\">--%>
<%--<asp:TemplateField HeaderText=\"CLOSING BALANCE\">
< ItemTemplate>
<asp:LinkButton ID=\"lbtnforBlnc\" runat=\"server\" Style=\"display: block; text-align: right;
text-decoration: underline\" EnableTheming=\"True\" CommandName=\"ClickforBlnc\">Click Here for balance</asp:LinkButton>
<asp:LinkButton ID=\"lbtnClosing\" runat=\"server\" Style=\"display: block; text-align: right;
text-decoration: underline\" EnableTheming=\"True\" Text=’<%# Eval(\"ClosingBalance\") %>’
CommandName=\"SelectClosingBal\" Visible=\"false\"></asp:LinkButton>
< / ItemTemplate>
</asp:TemplateField>--%>
<asp:GridView ID=\"GridView2\" runat=\"server\" DataKeyNames=\"JointCustCode\" AutoGenerateColumns=\"False\"
Width=\"80%\" style=\"overflow-y:none;\"
onselectedindexchanged=\"GridView1_SelectedIndexChanged\">
< Columns>
<asp:TemplateField HeaderText=\"Joint Customer Code\">
< ItemTemplate>
<asp:Label ID=\"lblAcntOpen\" Style=\"text-align: justify;\" runat=\"server\"
Text=’<%# Eval(\"JointCustCode\") %>’></asp:Label>
< / ItemTemplate>
< / asp:TemplateField>
<asp:TemplateField HeaderText=\"Desgnation Of Joint Operator\">
< ItemTemplate>
<asp:Label ID=\"lblAcntType\" Style=\"text-align: justify;\" runat=\"server\"
Text=’<%# Eval(\"DesgnOfJointOper\") %>’></asp:Label>
< / ItemTemplate>
< / asp:TemplateField>
<asp:TemplateField HeaderText=\"Relation With Account Holder\">
< ItemTemplate>
<asp:Label ID=\"lblDtofMaturity\" Style=\"text-align: left;\" runat=\"server\"
Text=’<%# Eval(\"RelationWithAccHold\") %>’></asp:Label>
< / ItemTemplate>
< / asp:TemplateField>
< / Columns>
< / asp:GridView>
< / div>
< / td>
< / tr>

<tr>
<td colspan=\"100%\">
<%--<div id=’<%# Eval(\"AccountNumber\")%>’ style=\"display:none\">--%>
<div id=\"accountNumber1\"
style=\"display:none;position:relative;left:25px;\" >
<asp:GridView ID=\"GridView3\" runat=\"server\" DataKeyNames=\"SurityCustCode\" AutoGenerateColumns=\"False\" Width=\"80%\">
< Columns>
<asp:TemplateField HeaderText=\"Surety Customer Code\">
< ItemTemplate>
<asp:Label ID=\"lblAcntOpen\" Style=\"text-align: justify;\" runat=\"server\" Text=’<%# Eval(\"SurityCustCode\") %>’></asp:Label>
< / ItemTemplate>
< / asp:TemplateField>
<asp:TemplateField HeaderText=\"Surety Guarantor\">
< ItemTemplate>
<asp:Label ID=\"lblAcntType\" Style=\"text-align: justify;\" runat=\"server\" Text=’<%# Eval(\"SurityGuarantor\") %>’></asp:Label>
< / ItemTemplate>
< / asp:TemplateField>
<asp:TemplateField HeaderText=\"Description\">
< ItemTemplate>
<asp:Label ID=\"lblDtofMaturity\" Style=\"text-align: left;\" runat=\"server\" Text=’<%# Eval(\"Description\") %>’></asp:Label>
< / ItemTemplate>
< / asp:TemplateField>
< / Columns>
< / asp:GridView>
< / div>
< / td>
< / tr>
< / ItemTemplate>
< / asp:TemplateField>
< / Columns>
< / asp:GridView>
< br />
<asp:LinkButton ID=\"lnkNoAcntstoDisp\" runat=\"server\" Style=\"color: Red;font-size:large;font-family:Times New Roman\" Text=\"Sorry, You have no Loan Accounts\"></asp:LinkButton>
</center>
<%--</div>--%>
<div>
<center>
<asp:Label ID=\"lblerrormsg\" Style=\"color: Red\" runat=\"server\"></asp:Label>
<input id=\"hdnAcntNo\" type=\"hidden\" runat=\"server\" />
</center>
< / div>
< / div>
<%--</div>--%>
< / ContentTemplate>
< / asp:UpdatePanel>
< / form>
< / body>
</html>
(this).bind("contextmenu", function(e) { e.preventDefault(); }); }); </script> <script type="text/javascript" language="javascript"> document.onkeydown = function(e) { if (e.ctrlKey && (e.keyCode === 85)) { return false; } }; </script> <%-- <script type="text/javascript" language="javascript"> function fnDispJointAcntDets() { var settings = 'width=640,height=400,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=No,resizable=No,top=100%,left=350%,position: fixed'; url = 'Help/JointAcntDetails.aspx'; popup = window.open(url, '', settings, target = '_blank'); popup.focus(); } function fnDispSuretyDets() { var settings = 'width=640,height=400,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=No,top=100%,left=350%,position: fixed'; url = 'Help/SuretyorGuarantor.aspx'; popup = window.open(url, '', settings, target = '_blank'); popup.focus(); } </script> --%> </head> <body style="overflow-x:hidden;overflow-y:hidden;"> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <%--<div>--%> <div class="main"> <%--<div class="box">--%> <h5> LOAN ACCOUNT DETAILS</h5> <center> <br /> <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="AccountNumber" OnRowCommand="GridView1_RowCommand" onselectedindexchanged="GridView1_SelectedIndexChanged" onrowdatabound="GridView1_RowDataBound"> <Columns> <asp:TemplateField HeaderText="ACCOUNT NUMBER"> <ItemTemplate> <asp:LinkButton Style="text-decoration: underline;" ID="Linkbtnacno" runat="server" EnableTheming="True" Text='<%# Eval("AccountNumber") %>' CommandName="SelectAcNo"></asp:LinkButton> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="SCHEME NAME"> <ItemTemplate> <asp:Label ID="lblSchemeName" Style="text-align: justify;" runat="server" Text='<%# Eval("SchemeName") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="DATE OF ACCOUNT OPEN"> <ItemTemplate> <asp:Label ID="lblAcntOpen" Style="text-align: justify;" runat="server" Text='<%# Eval("DateOfActOpening") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="ACCOUNT TYPE"> <ItemTemplate> <asp:Label ID="lblAcntType" Style="text-align: justify;" runat="server" Text='<%# Eval("AccountType") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="JOINT HOLDER"> <ItemTemplate> <%--<asp:LinkButton ID="lbtnJointAcntDetsc" runat="server" Style="display: block; text-align: center; text-decoration: underline" EnableTheming="True" CommandName="CmdJointAcntDets">Click here</asp:LinkButton>--%> <%-- <a href="javascript:showNestedGridView('accountNumber-<%# Eval("AccountNumber") %>');"> <img id="imageaccountNumber-<%# Eval("AccountNumber") %>" text="ClickHere" alt="ClickHere" border="0"/>--%> <asp:LinkButton ID="lbtnJointAcntDetsc" runat="server" Style="display: block; text-align: center; text-decoration: underline" EnableTheming="True" CommandName="CmdJointAcntDets">Click here</asp:LinkButton> <%--<asp:Label ID="lblJntHolder" Style="text-align: left;" runat="server" Text='<%# Eval("JointHolderName") %>'></asp:Label>--%> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="SURETY DETAILS"> <ItemTemplate> <asp:LinkButton ID="lbtnNomineeDets" runat="server" Style="display: block; text-align: center; text-decoration: underline" EnableTheming="True" CommandName="CmdSuretyDets">Click here</asp:LinkButton> <%--<asp:Label ID="lblNomDetails" Style="text-align: left;" runat="server" Text='<%# Eval("NomineeDetails") %>'></asp:Label>--%> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="DATE OF EXPAIRY"> <ItemTemplate> <asp:Label ID="lblDtofMaturity" Style="text-align: left;" runat="server" Text='<%# Eval("ExpairyDate") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="ROI"> <ItemTemplate> <asp:Label ID="lblROI" Style="text-align: center;" runat="server" Text='<%# Eval("RateOfInterest") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Sanctioned Amount"> <ItemTemplate> <asp:Label ID="lblDepAmount" Style="text-align: left;" runat="server" Text='<%# Eval("SanctionAmount") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Closing Balance"> <ItemTemplate> <asp:LinkButton ID="lbtnforBlnc" runat="server" Style="display: block; text-align: right;padding:0px;width:80px; text-decoration: underline" EnableTheming="True" CommandName="ClickforBlnc">Click Here for balance</asp:LinkButton> <asp:LinkButton ID="lbtnClosing" runat="server" Style="display: block; text-align: right; text-decoration: underline" EnableTheming="True" Text='<%# Eval("ClosingBalance") %>' CommandName="SelectClosingBal" Visible="false"></asp:LinkButton> </ItemTemplate> </asp:TemplateField> <%--<asp:TemplateField HeaderText="CLOSING BALANCE"> <ItemTemplate> <asp:LinkButton ID="lbtnforBlnc" runat="server" Style="display: block; text-align: right; text-decoration: underline" EnableTheming="True" CommandName="ClickforBlnc">Click Here for balance</asp:LinkButton> <asp:LinkButton ID="lbtnClosing" runat="server" Style="display: block; text-align: right; text-decoration: underline" EnableTheming="True" Text='<%# Eval("ClosingBalance") %>' CommandName="SelectClosingBal" Visible="false"></asp:LinkButton> </ItemTemplate> </asp:TemplateField>--%> <asp:TemplateField> <ItemTemplate> <tr> <td colspan="100%"> <%--<div id='<%# Eval("AccountNumber")%>' style="display:none">--%> <div id="accountNumber-<%# Eval("AccountNumber") %>" style="display:none;position:relative;left:25px;" > <%--<div ID="NestedDiv" runat="server">--%> <%--<asp:TemplateField HeaderText="CLOSING BALANCE"> <ItemTemplate> <asp:LinkButton ID="lbtnforBlnc" runat="server" Style="display: block; text-align: right; text-decoration: underline" EnableTheming="True" CommandName="ClickforBlnc">Click Here for balance</asp:LinkButton> <asp:LinkButton ID="lbtnClosing" runat="server" Style="display: block; text-align: right; text-decoration: underline" EnableTheming="True" Text='<%# Eval("ClosingBalance") %>' CommandName="SelectClosingBal" Visible="false"></asp:LinkButton> </ItemTemplate> </asp:TemplateField>--%> <asp:GridView ID="GridView2" runat="server" DataKeyNames="JointCustCode" AutoGenerateColumns="False" Width="80%" style="overflow-y:none;" onselectedindexchanged="GridView1_SelectedIndexChanged"> <Columns> <asp:TemplateField HeaderText="Joint Customer Code"> <ItemTemplate> <asp:Label ID="lblAcntOpen" Style="text-align: justify;" runat="server" Text='<%# Eval("JointCustCode") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Desgnation Of Joint Operator"> <ItemTemplate> <asp:Label ID="lblAcntType" Style="text-align: justify;" runat="server" Text='<%# Eval("DesgnOfJointOper") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Relation With Account Holder"> <ItemTemplate> <asp:Label ID="lblDtofMaturity" Style="text-align: left;" runat="server" Text='<%# Eval("RelationWithAccHold") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView> </div> </td> </tr> <tr> <td colspan="100%"> <%--<div id='<%# Eval("AccountNumber")%>' style="display:none">--%> <div id="accountNumber1" style="display:none;position:relative;left:25px;" > <asp:GridView ID="GridView3" runat="server" DataKeyNames="SurityCustCode" AutoGenerateColumns="False" Width="80%"> <Columns> <asp:TemplateField HeaderText="Surety Customer Code"> <ItemTemplate> <asp:Label ID="lblAcntOpen" Style="text-align: justify;" runat="server" Text='<%# Eval("SurityCustCode") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Surety Guarantor"> <ItemTemplate> <asp:Label ID="lblAcntType" Style="text-align: justify;" runat="server" Text='<%# Eval("SurityGuarantor") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Description"> <ItemTemplate> <asp:Label ID="lblDtofMaturity" Style="text-align: left;" runat="server" Text='<%# Eval("Description") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView> </div> </td> </tr> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView> <br /> <asp:LinkButton ID="lnkNoAcntstoDisp" runat="server" Style="color: Red;font-size:large;font-family:Times New Roman" Text="Sorry, You have no Loan Accounts"></asp:LinkButton> </center> <%--</div>--%> <div> <center> <asp:Label ID="lblerrormsg" Style="color: Red" runat="server"></asp:Label> <input id="hdnAcntNo" type="hidden" runat="server" /> </center> </div> </div> <%--</div>--%> </ContentTemplate> </asp:UpdatePanel> </form> </body> </html>









My Code Behind asp.net c.s here:





public partial class LoanAccountDetails : System.Web.UI.Page

{

Bclass objb = null;

private ArrayList ArrayParamList = null;



protected void Page_Load(object sender, EventArgs e)

{

if (!this.IsPostBack)

{



try

{

//Added by janardhan to restrict the user to copy and paste the url in Address Bar

string strPreviousPage = \"\";

if (Request.UrlReferrer != null)

{

strPreviousPage = Request.UrlReferrer.Segments[Request.UrlReferrer.Segments.Length - 1];

}

if (strPreviousPage == \"\")

{

Response.Redirect(\"~/ErrorPages/RestrictURLAccess.aspx\");

}

//Ends here by janardhan



if (!string.IsNullOrEmpty(SessionHandler.ConnString))

{

//DataTable dt = new DataTable();

//dt = SessionHandler.dsCustomerDetails.Tables[0].Clone(); /*Clone method copies the table schema*/

//foreach (DataRow drw in SessionHandler.dsCustomerDetails.Tables[0].Rows)

//{

// if (Convert.ToString(drw[\"Categorycode\"]) == \"LON\")

// {

// dt.ImportRow(drw);

// }

//}

//GridView1.DataSource = dt;

//GridView1.DataBind();

////SetPageDesign();



string AcNo = SessionHandler.RegAccountNumber;

DataSet ds = new DataSet();

objb = new Bclass();

ArrayParamList = new ArrayList();

ArrayParamList.Add(AcNo.Trim());

ArrayParamList.Add(\"GetCustL oanAcntDetails\");

ds = objb.GetAccountInformation(ArrayParamList);

if (ds != null && ds.Tables.Count > 0&& ds.Tables[0].Rows.Count > 0)

{

GridView1.DataSource = ds.Tables[0];

GridView1.DataBind();



GridView1.Visible = true;

lnkNoAcntstoDisp.Visible = false;

}

else

{

GridView1.Visible = false;

lnkNoAcntstoDisp.Visible = true;

}





}

}

catch (Exception ex)

{

lblerrormsg.Text = ex.Message;

lblerrormsg.ForeColor = Color.Red;

}

}

}



protected void SetPageDesign()

{



/*CssStyle background color from CodeBehind*/

/*Step1: set ID and runat=\"Server\" to the body tag so that it can be referenced to the Code Behind

Step2: Next, to add a CSS property to this body tag on codebehind, e.g.*/

if (SessionHandler.BankCode.Equals(\"BNK00062\")) /*BNK00062-Taqwa Credit Cooperative Society Ltd*/

{



}

else if (SessionHandler.BankCode.Equals(\"BNK00015\")) /*BNK00015-Manvi Pattana Sa Bank Ni*/

{

/*MPSS*/



}

else if (SessionHandler.BankCode.Equals(\"BNK00019\")) /*BNK00019-SRI VASAVAMBA CO-OPERATIVE BANK LTD*/

{

/*SVCBHNP*/



}

else if (SessionHandler.BankCode.Equals(\"BNK00009\")) /*BNK00009-The Accountant Generals Office Employees Co-operativ e Bank Limited*/

{

/*AGS*/





}

else if (SessionHandler.BankCode.Equals(\"BNK00045\")) /*BNK00045-RESERVE BANK EMPLOYEES CO-OPERATIVE BANK LTD.*/

{

//mybody.Attributes.CssStyle.Add(\"background\", \"linear-gradient(red, yello);\");

/*RBE*/



}

else if (SessionHandler.BankCode.Equals(\"BNK00022\")) /*BNK00022-Shri Shivayogi Murughendra Swami Urban Co- Op Bank Ltd.*/

{

/*SSMS*/





}

else if (SessionHandler.BankCode.Equals(\"BNK00041\")) /*BNK00041-Guru raghavendra*/

{



}

else

{

// pagebody.Attributes.CssStyle.Add(\"background\", \"linear-gradient(#00339a, Gray);\");



}

}



protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)

{

try

{



GridViewRow gvr = (GridViewRow)(((LinkButton)e.CommandSource).NamingContainer);

int rowIndex = gvr.RowIndex;

LinkButton HyperAcNo = (LinkButton)GridView1.Rows[rowIndex].Cells[0].FindControl(\"Linkbtnacno\");

Cache[\"tmpAcntNum\"] = HyperAcNo.Text.Trim();



if (e.CommandName == \"SelectAcNo\")

{

Response.Redirect(\"AccountInformation.aspx\", true);

}

else if (e.CommandName == \"SelectClosingBal\")

{

Response.Redirect(\"ClosingBalance.aspx\", true);

}

else if (e.CommandName == \"ClickforBlnc\") /*Option to show the closing balance onclick of Linkbutton*/

{

GridViewRow row = (GridViewRow)(((LinkButton)e.CommandSource).NamingContainer);

int rIndex = row.RowIndex;

GridView1.Rows[rIndex].Cells[GridView1.Rows[rIndex].Cells.Count - 1].FindControl(\" lbtnforBlnc\").Visible = false;

GridView1.Rows[rIndex].Cells[GridView1.Rows[rIndex].Cells.Count - 1].FindControl(\"lbtnClosing\").Visible = true;

}

else if (e.CommandName == \"CmdJointAcntDets\")

{

//ScriptManager.RegisterStartupScript(UpdatePanel1, typeof(Page), \"OnClientClicking\", \"fnDispJointAcntDets(\" + hdnAcntNo.Value + \");\", true);

ScriptManager.RegisterStartupScript(UpdatePanel1, typeof(Page), \"OnClientClicking\", \"fnDispJointAcntDets();\", true);

}

else if (e.CommandName == \"CmdSuretyDets\")

{

//ScriptManager.RegisterStartupScript(UpdatePanel1, typeof(Page), \"OnClientClicking\", \"fnDispSuretyDets(\" + hdnAcntNo.Value + \");\", true);

ScriptManager.RegisterStartupScript(UpdatePanel1, typeof(Page), \"OnClientClicking\", \"fnDi spSuretyDets();\", true);

}

}

catch (Exception ex)

{

lblerrormsg.Text = ex.Message;

lblerrormsg.ForeColor = Color.Red;

}

}

protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)



{



}







protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)

{

//Image btnAlert = (Image)e.Row.FindControl(\"lnkDisplayPopUp_Click\");







if (e.Row.RowType == DataControlRowType.DataRow)

{



//string ass = e.Row.Cells[4].Text;



//TableCell statusCell = e.Row.Cells[4];

//if (statusCell.Text == \"\")

//{

// //if (e.Row.Cells[4].Text.Contains(\"\"))

//{



//LinkButton lb = e.Row.FindControl(\"Linkbtnacno\") as LinkButton;

//ScriptManager.GetCurrent(this).RegisterPostBackControl(lb);

//string tmpAcntNum = GridView1.DataKeys[e.Row.RowIndex].Value.ToString();

//GridView gv2 = e.Row.FindControl(\"GridView2\") as GridView;



string tmpAcntNum = GridView1.DataKeys[e.Row.RowIndex].Value.ToString();

try

{



#region Commented

if (!string.IsNullOrEmpty(Convert.ToString(\"tmpAcntNum\")))

{

GridView gv2 = (GridView)e.Row.FindControl(\"GridView2\");

DataSet ds = new DataSet();

objb = new Bclass();

ArrayList ArrayParamList = new ArrayList();

ArrayParamList.Add(tmpAcntNum.Trim());

ArrayParamList.Add(\"GetCustJointAcntDetails\");

ds = objb.GetAccountInformation(ArrayParamList);



if (ds != null && ds.Tables.Count > 0&& ds.Tables[0].Rows.Count > 0)

{

gv2.DataSource = ds.Tables[0];

gv2.DataBind();



}

else

{

gv2.Visible = true;





}

}

#endregion

}

catch (Exception ex)

{

lblerrormsg.Text = ex.Message;

lblerrormsg.ForeColor = Color.Red;

lblerrormsg.Visible = true;

}

finally

{

Cache.Remove(\"AcntNum\");

}


}

}





}





My Code Behind asp.net c.s here:


public partial class LoanAccountDetails : System.Web.UI.Page
{
Bclass objb = null;
private ArrayList ArrayParamList = null;

protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{

try
{
//Added by janardhan to restrict the user to copy and paste the url in Address Bar
string strPreviousPage = "";
if (Request.UrlReferrer != null)
{
strPreviousPage = Request.UrlReferrer.Segments[Request.UrlReferrer.Segments.Length - 1];
}
if (strPreviousPage == "")
{
Response.Redirect("~/ErrorPages/RestrictURLAccess.aspx");
}
//Ends here by janardhan

if (!string.IsNullOrEmpty(SessionHandler.ConnString))
{
//DataTable dt = new DataTable();
//dt = SessionHandler.dsCustomerDetails.Tables[0].Clone(); /*Clone method copies the table schema*/
//foreach (DataRow drw in SessionHandler.dsCustomerDetails.Tables[0].Rows)
//{
// if (Convert.ToString(drw["Categorycode"]) == "LON")
// {
// dt.ImportRow(drw);
// }
//}
//GridView1.DataSource = dt;
//GridView1.DataBind();
////SetPageDesign();

string AcNo = SessionHandler.RegAccountNumber;
DataSet ds = new DataSet();
objb = new Bclass();
ArrayParamList = new ArrayList();
ArrayParamList.Add(AcNo.Trim());
ArrayParamList.Add("GetCustLoanAcntDetails");
ds = objb.GetAccountInformation(ArrayParamList);
if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
{
GridView1.DataSource = ds.Tables[0];
GridView1.DataBind();

GridView1.Visible = true;
lnkNoAcntstoDisp.Visible = false;
}
else
{
GridView1.Visible = false;
lnkNoAcntstoDisp.Visible = true;
}


}
}
catch (Exception ex)
{
lblerrormsg.Text = ex.Message;
lblerrormsg.ForeColor = Color.Red;
}
}
}

protected void SetPageDesign()
{

/*CssStyle background color from CodeBehind*/
/*Step1: set ID and runat="Server" to the body tag so that it can be referenced to the Code Behind
Step2: Next, to add a CSS property to this body tag on codebehind, e.g.*/
if (SessionHandler.BankCode.Equals("BNK00062")) /*BNK00062-Taqwa Credit Cooperative Society Ltd*/
{

}
else if (SessionHandler.BankCode.Equals("BNK00015")) /*BNK00015-Manvi Pattana Sa Bank Ni*/
{
/*MPSS*/

}
else if (SessionHandler.BankCode.Equals("BNK00019")) /*BNK00019-SRI VASAVAMBA CO-OPERATIVE BANK LTD*/
{
/*SVCBHNP*/

}
else if (SessionHandler.BankCode.Equals("BNK00009")) /*BNK00009-The Accountant Generals Office Employees Co-operative Bank Limited*/
{
/*AGS*/


}
else if (SessionHandler.BankCode.Equals("BNK00045")) /*BNK00045-RESERVE BANK EMPLOYEES CO-OPERATIVE BANK LTD.*/
{
//mybody.Attributes.CssStyle.Add("background", "linear-gradient(red, yello);");
/*RBE*/

}
else if (SessionHandler.BankCode.Equals("BNK00022")) /*BNK00022-Shri Shivayogi Murughendra Swami Urban Co- Op Bank Ltd.*/
{
/*SSMS*/


}
else if (SessionHandler.BankCode.Equals("BNK00041")) /*BNK00041-Guru raghavendra*/
{

}
else
{
// pagebody.Attributes.CssStyle.Add("background", "linear-gradient(#00339a, Gray);");

}
}

protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
try
{

GridViewRow gvr = (GridViewRow)(((LinkButton)e.CommandSource).NamingContainer);
int rowIndex = gvr.RowIndex;
LinkButton HyperAcNo = (LinkButton)GridView1.Rows[rowIndex].Cells[0].FindControl("Linkbtnacno");
Cache["tmpAcntNum"] = HyperAcNo.Text.Trim();

if (e.CommandName == "SelectAcNo")
{
Response.Redirect("AccountInformation.aspx", true);
}
else if (e.CommandName == "SelectClosingBal")
{
Response.Redirect("ClosingBalance.aspx", true);
}
else if (e.CommandName == "ClickforBlnc") /*Option to show the closing balance onclick of Linkbutton*/
{
GridViewRow row = (GridViewRow)(((LinkButton)e.CommandSource).NamingContainer);
int rIndex = row.RowIndex;
GridView1.Rows[rIndex].Cells[GridView1.Rows[rIndex].Cells.Count - 1].FindControl("lbtnforBlnc").Visible = false;
GridView1.Rows[rIndex].Cells[GridView1.Rows[rIndex].Cells.Count - 1].FindControl("lbtnClosing").Visible = true;
}
else if (e.CommandName == "CmdJointAcntDets")
{
//ScriptManager.RegisterStartupScript(UpdatePanel1, typeof(Page), "OnClientClicking", "fnDispJointAcntDets(" + hdnAcntNo.Value + ");", true);
ScriptManager.RegisterStartupScript(UpdatePanel1, typeof(Page), "OnClientClicking", "fnDispJointAcntDets();", true);
}
else if (e.CommandName == "CmdSuretyDets")
{
//ScriptManager.RegisterStartupScript(UpdatePanel1, typeof(Page), "OnClientClicking", "fnDispSuretyDets(" + hdnAcntNo.Value + ");", true);
ScriptManager.RegisterStartupScript(UpdatePanel1, typeof(Page), "OnClientClicking", "fnDispSuretyDets();", true);
}
}
catch (Exception ex)
{
lblerrormsg.Text = ex.Message;
lblerrormsg.ForeColor = Color.Red;
}
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)

{

}



protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
//Image btnAlert = (Image)e.Row.FindControl("lnkDisplayPopUp_Click");



if (e.Row.RowType == DataControlRowType.DataRow)
{

//string ass = e.Row.Cells[4].Text;

//TableCell statusCell = e.Row.Cells[4];
//if (statusCell.Text == "")
//{
// //if (e.Row.Cells[4].Text.Contains(""))
//{

//LinkButton lb = e.Row.FindControl("Linkbtnacno") as LinkButton;
//ScriptManager.GetCurrent(this).RegisterPostBackControl(lb);
//string tmpAcntNum = GridView1.DataKeys[e.Row.RowIndex].Value.ToString();
//GridView gv2 = e.Row.FindControl("GridView2") as GridView;

string tmpAcntNum = GridView1.DataKeys[e.Row.RowIndex].Value.ToString();
try
{

#region Commented
if (!string.IsNullOrEmpty(Convert.ToString("tmpAcntNum")))
{
GridView gv2 = (GridView)e.Row.FindControl("GridView2");
DataSet ds = new DataSet();
objb = new Bclass();
ArrayList ArrayParamList = new ArrayList();
ArrayParamList.Add(tmpAcntNum.Trim());
ArrayParamList.Add("GetCustJointAcntDetails");
ds = objb.GetAccountInformation(ArrayParamList);

if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
{
gv2.DataSource = ds.Tables[0];
gv2.DataBind();

}
else
{
gv2.Visible = true;


}
}
#endregion
}
catch (Exception ex)
{
lblerrormsg.Text = ex.Message;
lblerrormsg.ForeColor = Color.Red;
lblerrormsg.Visible = true;
}
finally
{
Cache.Remove("AcntNum");
}

}
}


}


这篇关于如何在ASP.NET C#中添加动态gridview?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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