重新绑定gridview并使用回调显示modelpopup [英] Rebind gridview and show modelpopup using callback

查看:66
本文介绍了重新绑定gridview并使用回调显示modelpopup的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在使用客户端回调机制重新绑定网格并在文本框F2 press(onkeyup event)上显示modelpopup.代码如下:

.aspx页面

Hi every one,

I am using client call back mechanism to rebind the grid and show modelpopup on textbox F2 press(onkeyup event). The code is as follows :

.aspx page

<asp:TextBox ID="txtReasonsForDelay" runat="server" AutoPostBack="false" Text=''<%#Bind("ReasonForDelay")%>'' MaxLength="1000" TextMode="multiline" ToolTip="Enter Reasons For Delay or select list of Reasons."></asp:TextBox>



上面的文本框在窗体视图中.以下数据与gridview中的modelpopup和面板相关.



The above textbox is in form view. The below data is related to modelpopup, panel within gridview

<cc1:ModalPopupExtender ID="modelPopupReason" runat="server" BackgroundCssClass="modalBackground"
                            TargetControlID="hiddenbuttonSort" PopupControlID="panelReasons" OkControlID=""
                            CancelControlID="" >
                        </cc1:ModalPopupExtender>
                        <asp:Button Style="display: none" ID="hiddenbuttonSort" runat="server"></asp:Button>
                        <td colspan="2" align="center">
                            <asp:Panel ID="panelReasons" CssClass="modalPopup" Style="display: none; overflow: auto"
                                Width="860px" Height="550px" runat="server">                                
                                <br />
                                <asp:Button ID="btnOk1" Visible="true" OnClick="btnOk_Click" runat="server" Width="60px"
                                    Text="OK" CssClass="button"></asp:Button>
                                <asp:Button ID="btnCancel1" Visible="true" OnClick="btnCancel_Click" runat="server"
                                    Width="80px" Text="Cancel" CssClass="button"></asp:Button>
                                <br />
                                <br />
                                <asp:GridView ID="grvReasons" runat="server" Width="100%" PageSize="50" GridLines="None"
                                    BorderStyle="None" Caption=''<table width="100%" class="tableheading"><tr><td>Select Reasons For Delay</td></tr></table>''
                                    DataSourceID="ObjectDataSourceReasons" CellPadding="4" AutoGenerateColumns="False"
                                     OnRowDataBound="grvReasons_RowDataBound" AllowSorting="true" ForeColor="#333333"
                                    OnSorted="grvReasons_OnSorted" OnDataBound="grvReasons_DataBound">
                                    <FooterStyle BackColor="#990000" ForeColor="White" Font-Bold="True"></FooterStyle>                                    
                                    <Columns>
                                        <asp:TemplateField>
                                            <HeaderTemplate>
                                                <asp:CheckBox ID="chkSelectAll" runat="server" />
                                            </HeaderTemplate>
                                            <ItemStyle Width="2%" CssClass="gridcontrolstyle" HorizontalAlign="Center"></ItemStyle>
                                            <HeaderStyle Width="2%" CssClass="gridcontrolstyle" HorizontalAlign="Center"></HeaderStyle>                                                                                     
                                            <ItemTemplate>
                                                <asp:CheckBox ID="chkSelect" runat="server" />
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="Reason For Delay" SortExpression="Reason">
                                            <ItemStyle Width="80%" HorizontalAlign="Left" CssClass="gridcontrolstyle"></ItemStyle>
                                            <HeaderStyle Width="80%" HorizontalAlign="Left" CssClass="gridcontrolstyle" ForeColor="Black">
                                            </HeaderStyle>
                                            <ItemTemplate>
                                                <asp:Label ID="lblReasons" runat="server" Text=''<%# Bind("Reason") %>''></asp:Label>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:CommandField SelectText="" ShowSelectButton="True">
                                            <ControlStyle Width="0px"></ControlStyle>
                                        </asp:CommandField>
                                    </Columns>
                                    <RowStyle CssClass="modelpopupdatarow"></RowStyle>
                                    <SelectedRowStyle CssClass="modelpopupdatarow"></SelectedRowStyle>
                                    <HeaderStyle CssClass="modelpopupheaderrow"></HeaderStyle>
                                    <AlternatingRowStyle CssClass="alternativecolumnvalue"></AlternatingRowStyle>                                
                                </asp:GridView>
                                <asp:ObjectDataSource ID="ObjectDataSourceReasons" runat="server" TypeName="AUSORD.Business.ReasonForDelayBL"
                                    SelectMethod="GetRecords" DataObjectTypeName="AUSORD.DataAccess.ReasonForDelay"
                                    SortParameterName="sortOrder">
                                    <SelectParameters>
                                        <asp:Parameter Type="string" DefaultValue="WO" Name="delayCategory"></asp:Parameter>
                                        <asp:Parameter Type="string" Name="sortOrder" />
                                    </SelectParameters>
                                </asp:ObjectDataSource>
                                <div align="left">
                                <asp:Label ID="lblReasonsError" Visible="false" runat="server" Text="No reasons are selected."></asp:Label>                                
                                <asp:Label ID="lblModelPopUpReasons" ForeColor="red" Visible="false" runat="server" 
                                Text="No Delay Reasons for Work Order are entered."></asp:Label>
                                </div>
                                <br />
                                <asp:Button ID="btnOk" Visible="true" OnClick="btnOk_Click" runat="server" Width="60px"
                                    Text="OK" CssClass="button"></asp:Button>
                                <asp:Button ID="btnCancel" Visible="true" OnClick="btnCancel_Click" runat="server"
                                    Width="80px" Text="Cancel" CssClass="button"></asp:Button>
                                
                            </asp:Panel>


在aspx.cs文件中,在页面加载中:


In aspx.cs file, In Page Load:

if (!IsCallback)
        {
            TextBox txtReasonsForDelay = (TextBox)frmWorkOrder.FindControl("txtReasonsForDelay");
            if (txtReasonsForDelay != null)
            {
                string getParameters = txtReasonsForDelay.ClientID + "," + modelPopupReason.ClientID + "," + grvReasons.Rows.Count;
                //System.Windows.Forms.KeyEventArgs e1 = new System.Windows.Forms.KeyEventArgs(System.Windows.Forms.Keys.F2);
                //if ((txtReasonsForDelay)e1.KeyCode == 113)
                //{
                //}
                txtReasonsForDelay.Attributes.Add("onkeyup", "txtReasonsForDelayKeyPress1('" + getParameters + "','"+ System.Windows.Forms.Keys.F2 +"')");                
            }
            ClientScriptManager cm = Page.ClientScript;
            String cbReference = cm.GetCallbackEventReference(this, "arg", "EndGetData", "context", false);
            cm.GetCallbackEventReference(this, "arg", "ReceiveServerData", "");
            String callbackScript = "function txtReasonsForDelayKeyPress1(arg, context) {" + cbReference + "; }";
            cm.RegisterClientScriptBlock(this.GetType(), "txtReasonsForDelayKeyPress1", callbackScript, true);
        }      

the client call back related procedures : 

public string GetCallbackResult()
    {
        return _Callback;
    }
    public void RaiseCallbackEvent(string eventArgument)
    {        
        grvReasons.DataBind();        
        _Callback = grvReasons.Rows.Count.ToString();
    }


javascript/client函数来调用服务器函数:


javascript/client function to call server function:

function EndGetData(arg,context)
		{
		    if(window.event.keyCode==113)
	        {
	            $find('ctl00_ContentPlaceHolder1_modelPopupReason').show();
	        }


问题:
1)当在与原因"记录相关的母版中创建新条目时,我调试并发现绑定正常工作.但是,它无法在modelpopup/gridview中显示新添加的记录.
2)我无法捕获键码,反而在javascript中出现期望的对象"错误

请解决我的问题或提出建议,因为我正在使用回调概念.


Problem :
1) when a new entry is made in masters related to the "reasons" record, i debug and find the bind works properly. But, it is unable to show the newly added records in modelpopup/gridview.
2) I am unable to capture keycode instead i get error as "object expected" in javascript

Please solve my problem or give some suggesions as i am using call back concept.

推荐答案

find(' ctl00_ContentPlaceHolder1_modelPopupReason').show(); }
find('ctl00_ContentPlaceHolder1_modelPopupReason').show(); }


问题:
1)当在与原因"记录相关的母版中创建新条目时,我调试并发现绑定正常工作.但是,它无法在modelpopup/gridview中显示新添加的记录.
2)我无法捕获键码,反而在javascript中出现期望的对象"错误

请解决我的问题或提出建议,因为我正在使用回叫概念.


Problem :
1) when a new entry is made in masters related to the "reasons" record, i debug and find the bind works properly. But, it is unable to show the newly added records in modelpopup/gridview.
2) I am unable to capture keycode instead i get error as "object expected" in javascript

Please solve my problem or give some suggesions as i am using call back concept.


这篇关于重新绑定gridview并使用回调显示modelpopup的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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