c# - Gridview in Modal Popup Extender- Postback Issues? -
i have c# .net application gridview within ajax modal popup (vs2008). have grid view set homecoming 10 records per page paging enabled.
when user clicks alter page within gridview there postback closes modal window , opens 1 time again using modalpopup.show();
is there way avoid postback of whole page , postback gridview whilst keeping modal window active? @ moment postback of whole page gives impression of flicker...
<asp:panel id="panel1" runat="server" font-italic="true" font-names="times new roman" font-size="small" forecolor="#82b8de"> <asp:gridview id="gridview1" runat="server" autogeneratecolumns="false" cellpadding="4" forecolor="#333333" gridlines="none" onpageindexchanging="gridview1_pageindexchanging" onrowdatabound="gridview1_rowdatabound" onselectedindexchanged="gridview1_selectedindexchanged" selectedindex="0" showheader="false" width="700px" controlid="gridview1" eventname="pageindexchanging" font-italic="true" font-names="times new roman" font-size="medium"> <pagersettings pagebuttoncount="12" /> <rowstyle cssclass="rowstyle" backcolor="#eff3fb" font-italic="true" font-names="times new roman" font-size="small" forecolor="#82b8de" /> <columns> <asp:boundfield datafield="address" readonly="true"> <itemstyle width="385px" /> </asp:boundfield> <asp:boundfield datafield="xcoord" readonly="true" showheader="false" > <itemstyle cssclass="hidden" /> </asp:boundfield> <asp:boundfield datafield="ycoord" readonly="true" showheader="false" > <itemstyle cssclass="hidden" /> </asp:boundfield> </columns> <footerstyle cssclass="footerstyle" backcolor="#507cd1" font-bold="true" forecolor="white" /> <pagerstyle backcolor="#2461bf" forecolor="white" horizontalalign="center" /> <selectedrowstyle cssclass="selectedrowstyle" backcolor="#d1ddf1" font-bold="true" forecolor="#333333" /> <headerstyle cssclass="headerstyle" backcolor="#507cd1" font-bold="true" forecolor="white" /> <editrowstyle backcolor="#2461bf" font-italic="true" font-names="times new roman" font-size="medium" /> <alternatingrowstyle backcolor="white" /> </asp:gridview> </asp:panel> <ajax:modalpopupextender id="modalpopupextender1" runat="server" popupcontrolid="panel1" targetcontrolid="dummy" backgroundcssclass="modalbackgroundgrid" behaviorid="modalgrid"> </ajax:modalpopupextender>
and code behind...
public void page_load(object sender, eventargs e) { seek { if (!(page.ispostback)) { gridview1.enableviewstate = true; gridview1.allowpaging = true; gridview1.pagesize = 10; gridview1.pagersettings.mode = pagerbuttons.numeric; gridview1.visible = true; } if (!m_bdisclaimershown) { m_bdisclaimershown = true; mpe1.show(); tabcontainer.visible = true; scalebar1.visible = true; } } grab (exception ex) { showmsg("error - " + ex.message); } } protected void btnhide_click(object sender, eventargs e) { mpe1.hide(); tabcontainer.visible = true; scalebar1.visible = true; } protected void cmdzoomaddress_click(object sender, eventargs e) { seek { if (txtpostcode.text.length >= 7 && opendb()) { string strpostcode = txtpostcode.text; strpostcode = strpostcode.substring(0, 4) + strpostcode.substring(strpostcode.length - 3, 3); sqlcommand sqlcmd = new sqlcommand(); sqlcmd.connection = m_sqlconn; sqlcmd.commandtype = system.data.commandtype.storedprocedure; sqlcmd.commandtext = "sde.dbo.sp_seladdressbypostcode"; sqlcmd.parameters.add("@postcode", sqldbtype.varchar); sqlcmd.parameters["@postcode"].value = strpostcode; sqldataadapter sqladapter = new sqldataadapter(sqlcmd); m_sqldatatable = new datatable(); sqladapter.fill(m_sqldatatable); gridview1.datasource = m_sqldatatable; gridview1.databind(); gridview1.visible = true; modalpopupextender1.show(); } else { showmsg("error - no postal addresses returned"); } } grab (exception ex) { showmsg("error - " + ex.message); } { closedb(); } } protected void gridview1_pageindexchanging(object sender, gridviewpageeventargs e) { if (sender != null) { gridview1.pageindex = e.newpageindex; gridview1.datasource = m_sqldatatable; gridview1.databind(); modalpopupextender1.show(); } } protected void gridview1_selectedindexchanged(object sender, eventargs e) { gridviewrow gvrow = gridview1.selectedrow; int ix = (int)convert.tosingle(gvrow.cells[1].text); int iy = (int)convert.tosingle(gvrow.cells[2].text); gridview1.visible = false; movemap(ix, iy); } public void gridview1_rowdatabound(object sender, gridviewroweventargs e) { if (e.row.dataitemindex >= 0) { e.row.attributes["style"] = "cursor:pointer"; e.row.attributes.add("onmouseover", "this.style.cursor='hand';"); e.row.attributes.add("onclick", clientscript.getpostbackeventreference(gridview1, "select$" + e.row.rowindex.tostring())); } } protected override void render(htmltextwriter writer) { foreach (gridviewrow r in gridview1.rows) { if (r.rowtype == datacontrolrowtype.datarow) { page.clientscript.registerforeventvalidation(gridview1.uniqueid, "select$" + r.rowindex); } } base.render(writer); }
thanks suggestion. i've set gridview a...
<asp:updatepanel> <contenttemplate>
the modal stays when click record in grid view doesn't close!
c# asp.net html ajax
No comments:
Post a Comment