网格中的Linkbutton(内部updatepanel)不绑定模态引导ASP.NET C#中的网格 [英] Linkbutton in grid (inside updatepanel) does not bind the grid in modal bootstrap ASP.NET C#

查看:63
本文介绍了网格中的Linkbutton(内部updatepanel)不绑定模态引导ASP.NET C#中的网格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我在模式中绑定gridview时遇到问题,绑定发生在另一个gridview标题中linkbutton的OnClick事件中。 br />


这是我的第一个gridview,标题中有linkbutton(lnkHistory)



 < asp:UpdatePanel ID =UpdatePanel2runat =server> 
< ContentTemplate>
< div class =tab-content>
< div role =tabpanelclass =tab-pane activeid =currentsa>
< div class =row>
< div class =col-sm-12>
< asp:GridView runat =serverID =gvSalaryAdvanceWidth =100%CssClass =table table-hoverAutoGenerateColumns =false
OnRowCreated =gvSalaryAdvance_RowCreated>
< Columns>
< asp:TemplateField ItemStyle-Width =15%>
< HeaderTemplate>
< asp:Label ID =lblStatusrunat =serverText =Status>< / asp:Label>
< asp:LinkBut​​ton ID =lnkHistoryrunat =serverOnClick =lnkHistory_Click>< span class =glyphicon glyphicon-exclamation-sign>< / span>< / asp :LinkBut​​ton的>
< / HeaderTemplate>
< ItemTemplate>
< asp:Label ID =lblStatusrunat =serverText ='<%#Eval(StatusStr)%>'>< / asp:Label>
< / ItemTemplate>
< / asp:TemplateField>
< / Columns>
< / asp:GridView>
< / div>
< / div>
< / ContentTemplate>
< / asp:UpdatePanel>





这是我在关闭lnkHistory按钮后绑定的gridview



 div id =modalSAHistoryclass =modal fade bd-example-modal-lgtabindex = -  1role =dialogdata-focus =truearia-labelledby = myLargeModalLabelstyle =margin-top:80pxaria-hidden =true> 
< div class =modal-dialog modal-lg>
< div class =modal-content>
< div class =modal-header>
< button type =buttonclass =closedata-dismiss =modalaria-label =关闭>< span aria-hidden =true>×< / span> ;< /按钮>
< h4 class =modal-title>历史< / h4>
< / div>
< div class =modal-body>
< div class =row>
< div class =form-group>
< div class =col-sm-12>
< asp:GridView runat =serverID =gvHistoryWidth =100%CssClass =table table-striped table-bordered table-hoverAutoGenerateColumns =false>
< Columns>
< asp:TemplateField HeaderText =StatusItemStyle-Width =15%>
< ItemTemplate>
< asp:Label ID =lblStatusrunat =serverText ='<%#Eval(StatusStr)%>'>< / asp:Label>
< / ItemTemplate>
< / asp:TemplateField>
< asp:TemplateField HeaderText =Marked ByItemStyle-Width =25%>
< ItemTemplate>
< asp:Label ID =lblModifiedByrunat =serverText ='<%#Eval(ModifiedBy)%>'>< / asp:Label>
< / ItemTemplate>
< / asp:TemplateField>
< / Columns>
< / asp:GridView>
< / div>
< / div>
< / div>
< / div>
< / div>
< / div>
< / div>





这是第一个gridview中lnkHistory的OnClick事件



 protected void lnkHistory_Click(object sender,EventArgs e)
{
string said =;
DataTable dt = new DataTable();
if(gvSalaryAdvance.Rows.Count> 0)
{
foreach(gvSalaryAdvance.Rows中的GridViewRow gvRow)
{
if(gvRow.RowType == DataControlRowType .DataRow)
{
HiddenField hdnSAID =(HiddenField)gvRow.FindControl(hdnSAID);
表示= hdnSAID.Value;


}
}
string [] param = {@ SA_ID};
string [] val = {said};
dt = SharedClass.getTableParam([sp_SA_getSalaryAdvanceLogs],param,val);
gvHistory.DataSource = dt;
gvHistory.DataBind();
}
ScriptManager.RegisterClientScriptBlock(Page,this.GetType(),AA,$('#modalSAHistory')。modal('show');,true);
}





我的尝试:



我还使用gridview的RowCreated事件将lnkHistory设置为postbacktrigger



 protected void gvSalaryAdvance_RowCreated(object sender,GridViewRowEventArgs e )
{
if(e.Row.RowType == DataControlRowType.Header)
{
ScriptManager scriptMan = ScriptManager.GetCurrent(this);
LinkBut​​ton btn = e.Row.FindControl(lnkHistory)作为LinkBut​​ton;

if(btn!= null)
{
scriptMan.RegisterAsyncPostBackControl(btn);
}
}
}









模态打开但它没有数据,我试图在绑定代码上断点。它检索数据并将其放入数据表并将其绑定到模态内的gridview,但模态为空。

解决方案

('#modalSAHistory')。modal ('show');,true);
}





我尝试过:



我还使用gridview的RowCreated事件将lnkHistory设置为postbacktrigger



 protected void gvSalaryAdvance_RowCreated(object sender,GridViewRowEventArgs e)
{
if(e.Row.RowType == DataControlRowType.Header)
{
ScriptManager scriptMan = ScriptManager.GetCurrent(这个);
LinkBut​​ton btn = e.Row.FindControl(lnkHistory)作为LinkBut​​ton;

if(btn!= null)
{
scriptMan.RegisterAsyncPostBackControl (btn);
}
}
}









模态打开但确实如此我没有数据,我试图破解绑定代码。它检索数据并将其放入数据表并将其绑定到模态内的gridview,但模态为空。


当我将模态放在gridview的更新面板中时,它已经工作了

Hi,

I am having a problem binding the gridview inside a modal, the binding occurs in the OnClick event of linkbutton in the header of another gridview.

Here's my first gridview with the linkbutton (lnkHistory) in the header

<asp:UpdatePanel ID="UpdatePanel2" runat="server">
       <ContentTemplate>
           <div class="tab-content">
               <div role="tabpanel" class="tab-pane active" id="currentsa">
                   <div class="row">
                       <div class="col-sm-12">
                           <asp:GridView runat="server" ID="gvSalaryAdvance" Width="100%" CssClass="table table-hover" AutoGenerateColumns="false"
                               OnRowCreated="gvSalaryAdvance_RowCreated">
                               <Columns>
                                   <asp:TemplateField ItemStyle-Width="15%">
                                       <HeaderTemplate>
                                           <asp:Label ID="lblStatus" runat="server" Text="Status"></asp:Label>
                                           <asp:LinkButton ID="lnkHistory" runat="server" OnClick="lnkHistory_Click"><span class="glyphicon glyphicon-exclamation-sign"></span></asp:LinkButton>
                                       </HeaderTemplate>
                                       <ItemTemplate>
                                           <asp:Label ID="lblStatus" runat="server" Text='<%# Eval("StatusStr") %>'></asp:Label>
                                       </ItemTemplate>
                                   </asp:TemplateField>
                               </Columns>
                           </asp:GridView>
                       </div>
                   </div>
       </ContentTemplate>
   </asp:UpdatePanel>



Here's the gridview I bind after clikcing the lnkHistory button

div id="modalSAHistory" class="modal fade bd-example-modal-lg" tabindex="-1" role="dialog" data-focus="true" aria-labelledby="myLargeModalLabel" style="margin-top: 80px" aria-hidden="true">
        <div class="modal-dialog modal-lg">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
                    <h4 class="modal-title">History</h4>
                </div>
                <div class="modal-body">
                    <div class="row">
                        <div class="form-group">
                            <div class="col-sm-12">
                                <asp:GridView runat="server" ID="gvHistory" Width="100%" CssClass="table table-striped table-bordered table-hover" AutoGenerateColumns="false">
                                    <Columns>
                                        <asp:TemplateField HeaderText="Status" ItemStyle-Width="15%">
                                            <ItemTemplate>
                                                <asp:Label ID="lblStatus" runat="server" Text='<%# Eval("StatusStr") %>'></asp:Label>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="Marked By" ItemStyle-Width="25%">
                                            <ItemTemplate>
                                                <asp:Label ID="lblModifiedBy" runat="server" Text='<%# Eval("ModifiedBy") %>'></asp:Label>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                    </Columns>
                                </asp:GridView>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>



Here's the OnClick event of lnkHistory inside the first gridview

protected void lnkHistory_Click(object sender, EventArgs e)
    {
        string said = "";
        DataTable dt = new DataTable();
        if (gvSalaryAdvance.Rows.Count > 0)
        {
            foreach (GridViewRow gvRow in gvSalaryAdvance.Rows)
            {
                if (gvRow.RowType == DataControlRowType.DataRow)
                {
                    HiddenField hdnSAID = (HiddenField)gvRow.FindControl("hdnSAID");
                    said = hdnSAID.Value;
                    
                    
                }
            }
            string[] param = { "@SA_ID" };
            string[] val = { said };
            dt = SharedClass.getTableParam("[sp_SA_getSalaryAdvanceLogs]", param, val);
            gvHistory.DataSource = dt;
            gvHistory.DataBind();
        }
        ScriptManager.RegisterClientScriptBlock(Page, this.GetType(), "AA", "$('#modalSAHistory').modal('show');", true);
    }



What I have tried:

I also set the lnkHistory as postbacktrigger using the RowCreated event of gridview

protected void gvSalaryAdvance_RowCreated(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.Header)
        {
            ScriptManager scriptMan = ScriptManager.GetCurrent(this);
            LinkButton btn = e.Row.FindControl("lnkHistory") as LinkButton;

            if (btn != null)
            {
                scriptMan.RegisterAsyncPostBackControl(btn);
            }
        }
    }





The modal opens but it does not have data, i tried to breakpoint on the code of binding. It retrieves the data and puts it in the datatable and binds it to the gridview inside the modal but the modal is empty.

解决方案

('#modalSAHistory').modal('show');", true); }



What I have tried:

I also set the lnkHistory as postbacktrigger using the RowCreated event of gridview

protected void gvSalaryAdvance_RowCreated(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.Header)
        {
            ScriptManager scriptMan = ScriptManager.GetCurrent(this);
            LinkButton btn = e.Row.FindControl("lnkHistory") as LinkButton;

            if (btn != null)
            {
                scriptMan.RegisterAsyncPostBackControl(btn);
            }
        }
    }





The modal opens but it does not have data, i tried to breakpoint on the code of binding. It retrieves the data and puts it in the datatable and binds it to the gridview inside the modal but the modal is empty.


Got it working when I placed the modal inside the update panel of gridview


这篇关于网格中的Linkbutton(内部updatepanel)不绑定模态引导ASP.NET C#中的网格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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