Showing posts with label gridview. Show all posts
Showing posts with label gridview. Show all posts

Monday, March 26, 2012

Multi-UpdatePanel Problem?

I have a imagebutton and a GridView on a simple web form. The GridView's datasource is a SqlDataSource that has a simple select statement in it. The GridView is inside an UpdatePanel, the ImageButton is not. There is no masterpage. EnablePartialRendering is set to true. When I run it, on the buttons click the GridView is made visible. When displayed the gridview sorts and pages correctly. However, once I add an UpdatePanel to the ImageButton the GridView displays as it should but will not sort or page. I have tried ever scenario I can think of, with Triggers, without Triggers, Mode Conditional, Mode Always. I am at a complete stand still. If anyone can explain what is happening here. I thought you could put as many Update Panels on a page as you wanted.

Thanks!

hello.

are you saying that when you put the linkbutton inside a panel it just stops working? any chance of building a small demo page with this?


Thanks for responding. I have included a test page with two updatepanel and one with only one update panel. I am still stumped. Please let me know what you think...Thanks again

1>>>>>>>>>>>Two UpdatePanel Page234<%@. Page Language="C#" AutoEventWireup="true" CodeFile="Test.aspx.cs" Inherits="Test" Title="Untitled Page" %>56<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">7<html xmlns="http://www.w3.org/1999/xhtml" >8910<atlas:ScriptManager ID="ScriptManager1" EnablePartialRendering="true" runat="server">1112</atlas:ScriptManager>13<head id="Head1" runat="server">1415</head>16<body>17<form id="form1" runat="server">18<div>19<table style="width: 100%; height: 100%; vertical-align: top; text-align: left;" >202122 <tr align="left">2324 <td valign="top" align="left">252627 <table style="width: 100%; border-right: thin solid;28 border-top: thin solid;29 border-left: thin solid;30 border-bottom: thin solid;">31 <tr style="border-right: thin solid;32 border-top: thin solid;33 border-left: thin solid;34 border-bottom: thin solid;35 width: 100%;36 height: 75px;">37 <td style="width: 25%; vertical-align: middle; text-align: left;">3839 <atlas:UpdatePanel ID="up1" runat="server" Mode="Always">40 <ContentTemplate>41 <asp:ImageButton ID="imbStart" runat="server" ImageUrl="~/images/Approve_32.jpg" OnClick="imbStart_Click" />42 </ContentTemplate>43 </atlas:UpdatePanel>4445 </td>4647 </tr>4849 <tr style="border-right: thin solid; border-top: thin solid; border-left: thin solid;50 width: 100%; border-bottom: thin solid">51 <td colspan="2" style="vertical-align: top; height: 100%; text-align: left">52 <atlas:UpdatePanel ID="UpdatePanel7" runat="server" Mode="Always">53 <ContentTemplate>5455  <asp:GridView ID="gvTrk" runat="server" Width="100%" Caption="Duplicates Trackers" AllowPaging="True" CaptionAlign="Top" Font-Bold="True" AllowSorting="True" AutoGenerateSelectButton="True" DataSourceID="SqlDataSource1" style="position: static" AutoGenerateColumns="False" OnSelectedIndexChanged="gvTrk_SelectedIndexChanged" Visible="False" >56 <Columns>57 <asp:BoundField DataField="UPS185_E_FF_ProdSvcU_ID" HeaderText="UPS185_E_FF_ProdSvcU_ID"58 InsertVisible="False" ReadOnly="True" SortExpression="UPS185_E_FF_ProdSvcU_ID" />59 <asp:CheckBoxField DataField="PrimaryPS_LG" HeaderText="PrimaryPS_LG" SortExpression="PrimaryPS_LG" />60 <asp:BoundField DataField="PkgType_VC" HeaderText="PkgType_VC" SortExpression="PkgType_VC" />61 <asp:BoundField DataField="ChargeCategoryCode_CH" HeaderText="ChargeCategoryCode_CH"62 SortExpression="ChargeCategoryCode_CH" />63 <asp:BoundField DataField="ChargeCategoryDetailCode_CH" HeaderText="ChargeCategoryDetailCode_CH"64 SortExpression="ChargeCategoryDetailCode_CH" />65 <asp:BoundField DataField="ChargeClassificationCode_VC" HeaderText="ChargeClassificationCode_VC"66 SortExpression="ChargeClassificationCode_VC" />67 <asp:BoundField DataField="ChargeDescriptionCode_VC" HeaderText="ChargeDescriptionCode_VC"68 SortExpression="ChargeDescriptionCode_VC" />69 <asp:BoundField DataField="SvcDesc_VC" HeaderText="SvcDesc_VC" SortExpression="SvcDesc_VC" />70 <asp:BoundField DataField="PS_Mstr_ID" HeaderText="PS_Mstr_ID" SortExpression="PS_Mstr_ID" />71 <asp:BoundField DataField="ModeCat_ID" HeaderText="ModeCat_ID" SortExpression="ModeCat_ID" />72 <asp:BoundField DataField="CWTByPkg_PS_ID" HeaderText="CWTByPkg_PS_ID" SortExpression="CWTByPkg_PS_ID" />73 <asp:BoundField DataField="Fuel_ID" HeaderText="Fuel_ID" SortExpression="Fuel_ID" />74 <asp:BoundField DataField="WgtLo_IN" HeaderText="WgtLo_IN" SortExpression="WgtLo_IN" />75 <asp:BoundField DataField="WgtHi_IN" HeaderText="WgtHi_IN" SortExpression="WgtHi_IN" />76 <asp:BoundField DataField="ZoneLo_IN" HeaderText="ZoneLo_IN" SortExpression="ZoneLo_IN" />77 <asp:BoundField DataField="ZoneHi_IN" HeaderText="ZoneHi_IN" SortExpression="ZoneHi_IN" />78 <asp:BoundField DataField="DIFSEX_CH" HeaderText="DIFSEX_CH" SortExpression="DIFSEX_CH" />79 <asp:CheckBoxField DataField="IsCWT_LG" HeaderText="IsCWT_LG" SortExpression="IsCWT_LG" />80 <asp:CheckBoxField DataField="IsRES_LG" HeaderText="IsRES_LG" SortExpression="IsRES_LG" />81 <asp:CheckBoxField DataField="ReRate_LG" HeaderText="ReRate_LG" SortExpression="ReRate_LG" />82 <asp:BoundField DataField="OStPv_CD" HeaderText="OStPv_CD" SortExpression="OStPv_CD" />83 <asp:BoundField DataField="DStPv_CD" HeaderText="DStPv_CD" SortExpression="DStPv_CD" />84 </Columns>85 <SelectedRowStyle BackColor="#FFC080" />86 <HeaderStyle BackColor="SandyBrown" Font-Names="Arial" Font-Size="8pt" />87 <AlternatingRowStyle BackColor="#E0E0E0" />88 </asp:GridView>89 </ContentTemplate>9091 </atlas:UpdatePanel>92 </td>93 </tr>9495 </table>96 <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:myEDIConnectionString%>"97 SelectCommand="SELECT UPS185_E_FF_ProdSvcU_T.* FROM UPS185_E_FF_ProdSvcU_T"></asp:SqlDataSource>98 </td>99 <td valign="top" align="left" style="width: 25px">100 </td>101 </tr>102 </table>103</div>104</form>105</body>106</html>107108109>>>>>>One Update Panel Page>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>110111112<%@. Page Language="C#" AutoEventWireup="true" CodeFile="Test.aspx.cs" Inherits="Test" Title="Untitled Page" %>113114<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">115<html xmlns="http://www.w3.org/1999/xhtml" >116117118<atlas:ScriptManager ID="ScriptManager1" EnablePartialRendering="true" runat="server">119120</atlas:ScriptManager>121<head id="Head1" runat="server">122123</head>124<body>125<form id="form1" runat="server">126<div>127<table style="width: 100%; height: 100%; vertical-align: top; text-align: left;" >128129130 <tr align="left">131132 <td valign="top" align="left">133134135 <table style="width: 100%; border-right: thin solid;136 border-top: thin solid;137 border-left: thin solid;138 border-bottom: thin solid;">139 <tr style="border-right: thin solid;140 border-top: thin solid;141 border-left: thin solid;142 border-bottom: thin solid;143 width: 100%;144 height: 75px;">145 <td style="width: 25%; vertical-align: middle; text-align: left;">146147148149 </td>150151 </tr>152153 <tr style="border-right: thin solid; border-top: thin solid; border-left: thin solid;154 width: 100%; border-bottom: thin solid">155 <td colspan="2" style="vertical-align: top; height: 100%; text-align: left">156 <atlas:UpdatePanel ID="UpdatePanel7" runat="server" Mode="Always">157 <ContentTemplate>158159  <asp:GridView ID="gvTrk" runat="server" Width="100%" Caption="Duplicates Trackers" AllowPaging="True" CaptionAlign="Top" Font-Bold="True" AllowSorting="True" AutoGenerateSelectButton="True" DataSourceID="SqlDataSource1" style="position: static" AutoGenerateColumns="False" OnSelectedIndexChanged="gvTrk_SelectedIndexChanged" Visible="False" >160 <Columns>161 <asp:BoundField DataField="UPS185_E_FF_ProdSvcU_ID" HeaderText="UPS185_E_FF_ProdSvcU_ID"162 InsertVisible="False" ReadOnly="True" SortExpression="UPS185_E_FF_ProdSvcU_ID" />163 <asp:CheckBoxField DataField="PrimaryPS_LG" HeaderText="PrimaryPS_LG" SortExpression="PrimaryPS_LG" />164 <asp:BoundField DataField="PkgType_VC" HeaderText="PkgType_VC" SortExpression="PkgType_VC" />165 <asp:BoundField DataField="ChargeCategoryCode_CH" HeaderText="ChargeCategoryCode_CH"166 SortExpression="ChargeCategoryCode_CH" />167 <asp:BoundField DataField="ChargeCategoryDetailCode_CH" HeaderText="ChargeCategoryDetailCode_CH"168 SortExpression="ChargeCategoryDetailCode_CH" />169 <asp:BoundField DataField="ChargeClassificationCode_VC" HeaderText="ChargeClassificationCode_VC"170 SortExpression="ChargeClassificationCode_VC" />171 <asp:BoundField DataField="ChargeDescriptionCode_VC" HeaderText="ChargeDescriptionCode_VC"172 SortExpression="ChargeDescriptionCode_VC" />173 <asp:BoundField DataField="SvcDesc_VC" HeaderText="SvcDesc_VC" SortExpression="SvcDesc_VC" />174 <asp:BoundField DataField="PS_Mstr_ID" HeaderText="PS_Mstr_ID" SortExpression="PS_Mstr_ID" />175 <asp:BoundField DataField="ModeCat_ID" HeaderText="ModeCat_ID" SortExpression="ModeCat_ID" />176 <asp:BoundField DataField="CWTByPkg_PS_ID" HeaderText="CWTByPkg_PS_ID" SortExpression="CWTByPkg_PS_ID" />177 <asp:BoundField DataField="Fuel_ID" HeaderText="Fuel_ID" SortExpression="Fuel_ID" />178 <asp:BoundField DataField="WgtLo_IN" HeaderText="WgtLo_IN" SortExpression="WgtLo_IN" />179 <asp:BoundField DataField="WgtHi_IN" HeaderText="WgtHi_IN" SortExpression="WgtHi_IN" />180 <asp:BoundField DataField="ZoneLo_IN" HeaderText="ZoneLo_IN" SortExpression="ZoneLo_IN" />181 <asp:BoundField DataField="ZoneHi_IN" HeaderText="ZoneHi_IN" SortExpression="ZoneHi_IN" />182 <asp:BoundField DataField="DIFSEX_CH" HeaderText="DIFSEX_CH" SortExpression="DIFSEX_CH" />183 <asp:CheckBoxField DataField="IsCWT_LG" HeaderText="IsCWT_LG" SortExpression="IsCWT_LG" />184 <asp:CheckBoxField DataField="IsRES_LG" HeaderText="IsRES_LG" SortExpression="IsRES_LG" />185 <asp:CheckBoxField DataField="ReRate_LG" HeaderText="ReRate_LG" SortExpression="ReRate_LG" />186 <asp:BoundField DataField="OStPv_CD" HeaderText="OStPv_CD" SortExpression="OStPv_CD" />187 <asp:BoundField DataField="DStPv_CD" HeaderText="DStPv_CD" SortExpression="DStPv_CD" />188 </Columns>189 <SelectedRowStyle BackColor="#FFC080" />190 <HeaderStyle BackColor="SandyBrown" Font-Names="Arial" Font-Size="8pt" />191 <AlternatingRowStyle BackColor="#E0E0E0" />192 </asp:GridView>193 </ContentTemplate>194195 </atlas:UpdatePanel>196 </td>197 </tr>198199 </table>200 <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:myEDIConnectionString%>"201 SelectCommand="SELECT UPS185_E_FF_ProdSvcU_T.* FROM UPS185_E_FF_ProdSvcU_T"></asp:SqlDataSource>202 </td>203 <td valign="top" align="left" style="width: 25px">204 </td>205 </tr>206 </table>207</div>208</form>209</body>210</html>211

multiview refresh inside updatepanel

i've a gridview based on the dropdownlist and multiview with two views based on the gridview selection.

when i change selection in my dropdownlist without click on my gridview, the information in the multiview in view1 and view2 is refreshed, but once i change the selection in my gridview the refresh happend only in the active view not in the other.

help me please

S.O.S ...Sos...sos...helpConfused


thanks to all for your reply!!!Wink.

i've found the solution it's working but i'm sure there is an other way and better.

when i change the selection in the gridview i refresh the sql connection.

and when i set the view1 or view2 to active i refresh the connection too.

gridveiw1.datasourceid="sqlconnectin1".

Must Click Twice for Event to Fire

I have an GridView with an Select link on each line. The link brings up a modal popup for editing data. The GridView is inside an updatepanel.

Everything works great, except for some reason, I have to click the Select link twice for the event to fire. The first click does nothing...does not enter the

SelectedIndexChanged event at all.

Anyone know why?

Wanna post your HTML here so we can take a peek?

WS


Sure here you go..

<%

@.ControlLanguage="vb"AutoEventWireup="false"Codebehind="Packer.ascx.vb"Inherits="WDE.Packer" %>

<%

@.RegisterAssembly="AjaxControlToolkit"Namespace="AjaxControlToolkit"TagPrefix="ajaxToolkit" %>

<

divid="PackerUpdatePanel"><asp:UpdatePanelID="UpdatePanelPackers"runat="server"UpdateMode="Conditional"><ContentTemplate><asp:PanelID="PanelPackersHeader"runat="server"CssClass="collapsePanelHeader"Height="30px"><divstyle="padding: 5px; vertical-align: middle;"><divstyle="float: left;"><asp:LabelID="LblPackers"runat="server"Text="Packers"></asp:Label></div><divstyle="float: left; margin-left: 5px;"><asp:LabelID="LblPackersCount"runat="server"></asp:Label></div><divstyle="float: right; vertical-align: middle; cursor: hand"><asp:ImageButtonID="ImageExpand"runat="server"ImageUrl="~/images/expand_blue.jpg"/></div><divstyle="float: right; margin-right: 20px;"></div></div></asp:Panel><asp:PanelID="PanelPackersViewDetails"runat="server"Height="100%"Width="100%"Wrap="False"><tableid="border"width="100%"cellpadding="0"cellspacing="0"><tr><tdclass="addHeader"><divstyle="float: right; margin-right: 1px;cursor: hand"><asp:LinkButtonID="HyperLinkAddPacker"runat="server"OnClick="HyperLinkAddPacker_Click"ForeColor="White"CssClass="hyperlinkNoLine">Add New Packer</asp:LinkButton></div></td></tr><tr><td><asp:GridViewID="packerGrid"runat="server"CellPadding="4"DataSourceID="PackersXmlDataSource"Width="100%"ForeColor="#333333"AutoGenerateColumns="False"GridLines="None"OnSelectedIndexChanged="packerGrid_SelectedIndexChanged"><FooterStyleBackColor="#5D7B9D"Font-Bold="True"ForeColor="White"/><RowStyleBackColor="#F7F6F3"ForeColor="#333333"/><EditRowStyleBackColor="#999999"/><SelectedRowStyleBackColor="#E2DED6"Font-Bold="True"ForeColor="#333333"/><PagerStyleBackColor="#284775"ForeColor="White"HorizontalAlign="Center"/><HeaderStyleBackColor="#5D7B9D"Font-Bold="True"ForeColor="White"/><AlternatingRowStyleBackColor="White"ForeColor="#284775"/><Columns><asp:CommandFieldShowSelectButton="True"SelectText="Edit"/><asp:BoundFieldDataField="packerDate"HeaderText="Date"SortExpression="packerDate"><ItemStyleHorizontalAlign="Left"/><HeaderStyleHorizontalAlign="Left"/></asp:BoundField><asp:BoundFieldDataField="packerOperation"HeaderText="Operation"SortExpression="packerOperation"><HeaderStyleHorizontalAlign="Left"/><ItemStyleHorizontalAlign="Left"/></asp:BoundField><asp:BoundFieldDataField="packerCode"HeaderText="Code"SortExpression="packerCode"><HeaderStyleHorizontalAlign="Left"/><ItemStyleHorizontalAlign="Left"/></asp:BoundField><asp:BoundFieldDataField="packerDepth"HeaderText="Depth"SortExpression="packerDepth"><HeaderStyleHorizontalAlign="Left"/><ItemStyleHorizontalAlign="Left"/></asp:BoundField><asp:CommandFieldButtonType="Image"DeleteImageUrl="~/Images/DELETE.jpg"ShowDeleteButton="True"/></Columns></asp:GridView></td></tr></table></asp:Panel><ajaxToolkit:CollapsiblePanelExtenderID="CollapsiblePanelExtenderPackers"runat="Server"TargetControlID="PanelPackersViewDetails"ExpandControlID="ImageExpand"CollapseControlID="ImageExpand"Collapsed="True"ExpandedImage="~/images/collapse_blue.jpg"CollapsedImage="~/images/expand_blue.jpg"ImageControlID="ImageExpand"SuppressPostBack="true"/></ContentTemplate></asp:UpdatePanel>

</

div>

<

divid="PackersMaintenancePanelDiv"><asp:ButtonID="FakePackerTarget"runat="server"Style="display: none"></asp:Button><ajaxToolkit:ModalPopupExtenderID="ModalPopupAddEditPacker"runat="server"TargetControlID="FakePackerTarget"PopupControlID="PanelPackerAddEdit"BackgroundCssClass="modalBackground"DropShadow="false"CancelControlID="btnCancel"/><asp:PanelID="PanelPackerAddEdit"runat="server"Width="45%"Wrap="False"Style="display: none"BorderStyle="Solid"BorderColor="#6b8aad"><asp:UpdatePanelID="UpdatePanelPackerModalPopup"runat="server"><ContentTemplate><tableid="AddPackTable"runat="server"style="width: 100%; background-color: white;"><tr><tdcolspan="3"style="font-size: 10pt; background-color: #6b8aad; color: White"><asp:LabelID="lblPackerHeader"runat="server"Text="Packer"></asp:Label></td></tr><tr><td><asp:LabelID="lblPackerDate"runat="server"Text="Date:"Width="78px"></asp:Label><br/></td><td><asp:TextBoxID="txtPackerDate"runat="server"></asp:TextBox><spanstyle="font-size: 10pt; color: #ff0033">* </span><asp:ImageButtonID="ImageBtnCalendar"runat="server"ImageUrl="~/Images/CalendarButton.gif"/><ajaxToolkit:PopupControlExtenderID="PopupControlExtenderPackerDate"runat="server"TargetControlID="ImageBtnCalendar"PopupControlID="PanelCalendar"Position="Bottom"/><spanstyle="font-size: 10pt">(yyyymmdd)</span></td><td><asp:RequiredFieldValidatorID="RequiredFieldValidator2"runat="server"ControlToValidate="txtPackerDate"ErrorMessage="RequiredFieldValidator"Display="Dynamic">Date is required.</asp:RequiredFieldValidator></td></tr><tr><td><asp:LabelID="lblPackerOperation"runat="server"Text="Operation:"></asp:Label></td><td><asp:RadioButtonListID="rblPakerOperation"runat="server"RepeatDirection="Horizontal"><asp:ListItemSelected="True"Value="P">Pulled</asp:ListItem><asp:ListItemValue="S">Set</asp:ListItem></asp:RadioButtonList></td><td></td></tr><tr><td><asp:LabelID="lblPackerCode"runat="server"Text="Code:"></asp:Label></td><td><asp:TextBoxID="txtBoxPackerCode"runat="server"></asp:TextBox><asp:ButtonID="btnPackerCodes"runat="server"Text=".."/><ajaxToolkit:PopupControlExtenderID="PopupControlExtenderPackerCodes"runat="server"TargetControlID="btnPackerCodes"PopupControlID="PanelPackerCode"Position="Bottom"/></td><td></td></tr><tr><td><asp:LabelID="lblPackerDepth"runat="server"Text="Depth:"></asp:Label></td><td><asp:TextBoxID="txtboxPackerDepth"runat="server"MaxLength="7"></asp:TextBox>mkb<spanstyle="font-size: 10pt; color: #ff0033">*</span></td><td><asp:RequiredFieldValidatorID="RequiredFieldValidator1"runat="server"ControlToValidate="txtboxPackerDepth"ErrorMessage="RequiredFieldValidator"Display="Dynamic">Depth is required.</asp:RequiredFieldValidator></td></tr><tr><tdcolspan="3"><hr/></td></tr><tr><td><spanstyle="color: #ff0033"><spanstyle="font-size: 10pt; color: #ff0033">*</span></span>-Required</td><td></td><tdstyle="width: 100%"><asp:ButtonID="btnPackerAddOk"runat="server"Text="Ok"/><asp:ButtonID="btnCancel"runat="server"Text="Cancel"OnClick="btnCancel_Click"CausesValidation="False"/></td></tr></table></ContentTemplate></asp:UpdatePanel></asp:Panel>

</

div>

<

divid="PanelCalendarDiv"><asp:PanelID="PanelCalendar"runat="server"CssClass="popupControl"Style="z-index: 10002"><asp:UpdatePanelID="UpdatePanelCalendar"runat="server"UpdateMode="Always"><ContentTemplate><center><asp:CalendarID="Calendar1"runat="server"BackColor="White"BorderColor="#999999"CellPadding="1"DayNameFormat="Shortest"Font-Names="Verdana"Font-Size="8pt"ForeColor="Black"Width="160px"OnSelectionChanged="Calendar1_SelectionChanged"><SelectedDayStyleBackColor="#666666"Font-Bold="True"ForeColor="White"/><TodayDayStyleBackColor="#CCCCCC"ForeColor="Black"/><SelectorStyleBackColor="#CCCCCC"/><WeekendDayStyleBackColor="#FFFFCC"/><OtherMonthDayStyleForeColor="#808080"/><NextPrevStyleVerticalAlign="Bottom"/><DayHeaderStyleBackColor="#CCCCCC"Font-Bold="True"Font-Size="7pt"/><TitleStyleBackColor="#999999"Font-Size="7pt"BorderColor="Black"Font-Bold="True"/></asp:Calendar></center></ContentTemplate></asp:UpdatePanel></asp:Panel>

</

div>

<

divid="PanelPackerCodeDiv"><asp:PanelID="PanelPackerCode"runat="server"CssClass="popupControl"Style="z-index: 10003"><asp:UpdatePanelID="UpdatePanel1"runat="server"><ContentTemplate><asp:RadioButtonListID="RblPackerCodes"runat="server"OnSelectedIndexChanged="RblPackerCodes_SelectedIndexChanged"AutoPostBack="true"><asp:ListItemValue="1">1 - Packer</asp:ListItem><asp:ListItemValue="2">2 - Bridge plug or whipstock packer</asp:ListItem><asp:ListItemValue="3">3 - Cement retainer</asp:ListItem><asp:ListItemValue="4">4 - Through tubing packer</asp:ListItem><asp:ListItemValue="5">5 - Through tubing bridge plug</asp:ListItem></asp:RadioButtonList></ContentTemplate></asp:UpdatePanel></asp:Panel>

</

div>

<

asp:XmlDataSourceID="PackersXmlDataSource"runat="server"DataFile="~/XML/Packers.xml">

</

asp:XmlDataSource>

<

asp:ObjectDataSourceID="PackersObjectDataSource"runat="server"DataObjectTypeName="Packer"DeleteMethod="DeletePacker"SelectMethod="GetPackers"TypeName="WellOperation"UpdateMethod="UpdatePacker"></asp:ObjectDataSource>

I'm having the same problem and have tried for 2 weeks to resolve without success. I have converted to the RC AJAX - still same issue. I have suspected that the problem revolves around a custom user control that is on my form. It is simply an alphabet selector with 26 letters as links.

I have traced the events and on the first click, the code goes as far as the constructor code for the user control and then simply stops. But then, as Janet wrote, the second click works just fine.

My completed project that has a GridView. How to "just add" Ajax?

Hi, I have a completed project, no changes need to be made, no modifications need to be done. Many modules contain GridViews and I notice the delay when posting back each time an item is selected. How can I adjust project to enable Ajax when selecting an item in the GridView?

Notice the emphasis I have put in that my project is "completed", my point is this, imagine the average programmer, working as a consultant, the boss behind each second checking up "recent updates", also studying so work hours have to be "work hours", in other words, no time to Google Ajax or buy Ajax for Dummies, get 2 weekends and start learning it from scratch, I am not saying I will not have the time ever, I will (I hope :p) but honestly, I need a way to work this out first, If I have to learn Ajax then I will learn Ajax enabling it in my gridviews.Yes

I think you'll enjoy this video:

Video - Developing ASP.NET 2.0 Applications using AJAX

by Scott Guthrie, General Manager, .NET Development Platform

One of the great features about ASP.NET AJAX is how easy it is to take an existing application and add rich client-side behavior to it using AJAX . In this video demonstration, Scott Guthrie creates a ToDo List application with ASP.NET 2.0 and then adds AJAX capabilities to it, using a preview "Atlas" release of ASP.NET AJAX .
(The video length is 18 minutes)

Watch this video


Thanks, and for those that does not know is this simple:

<form id="form1" runat="server">
<atlas:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true"/
<atlas:UpdatePanel runat="server" ID="UpdatePanel1" Mode="Conditional">
<ContentTemplate>

Add here controls and all will magically happen!!Big SmileBig Smile

</ContentTemplate>
</atlas:UpdatePanel>
</form>

Saturday, March 24, 2012

My gridview is not update

Hi,

I have an update panel in my page which contain a grid view.

I need to refresh my page periodically. I am using Timer for that. Here is my code

<asp:UpdatePanelID="UpdatePanel1"runat="server">

<ContentTemplate>

<asp:TimerID="Timer1"runat="server"Interval="10000">

</asp:Timer>

...................

<asp:GridViewID="GridView1"runat="server"SkinId="SampleGridView"CssSelectorClass="PrettyGridView"

DataKeyNames="ID"DataSourceID="SqlDataSource2"OnSelectedIndexChanged="GridView1_SelectedIndexChanged"

OnRowCommand="VerDiagramRed"Width="666px"OnDataBound="GridView1_DataBound"AutoGenerateColumns="False">

<Columns>

<asp:CommandFieldShowSelectButton="True"SelectText="Routers"/>

<asp:BoundFieldDataField="ID"HeaderText="ID"InsertVisible="False"ReadOnly="True"

SortExpression="ID"/>

<asp:BoundFieldDataField="Nombre"HeaderText="Nombre"SortExpression="Nombre"/>

<asp:BoundFieldDataField="Lectura"HeaderText="Lectura"SortExpression="Lectura"/>

<asp:BoundFieldDataField="Errores"HeaderText="Errores"SortExpression="Errores"/>

<asp:BoundFieldDataField="Estado"HeaderText="Estado"SortExpression="Estado"/>

<asp:ButtonFieldButtonType="Image"CommandName="diagram"HeaderText="Plano"

Text="Diagrama"ImageUrl="~/images/diagrama1.jpg"/>

</Columns>

</asp:GridView>

</ContentTemplate></asp:UpdatePanel>

DataGrid is not refreshed. What am doing wrong?

Thank you

Hi!

Follow these steps and it should work:

- Take the Timer out of the UpdatePanel.
- Set the UpdatePanel's properties UpdateMode="Conditional" and ChildrenAsTriggers="false"
- Add a trigger to the UpdatePanel's triggers collection:

<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1" EventName="OnTick" />
</Triggers>

Now, as you are doing something on OnSelectedIndexChanged and OnRowCommand, are you sure that you need the Timer at all? Is not enough to refresh the GridView on these events?

Anyway, don't forget to add triggers for each event you are handling.

Hope this helps,



You can use Timer Control & you can trigger it's OnTick event..

So that it will periodically refreshes the GridViewSmile


Thank you very much. I did what you said and it is working perfectly.

I need to do refresh periodically because the users needs to monitor the information in the gridview.

my javascript method not working with update panel

Hi All,

The gridview (inside a user control) i am using in my screen (.aspx page) have a Checkbox column in the end. When i click the checkbox in the header all the checkboxes are selected. (A long javascript code has been written for that in the user control)

Now I have applied a scriptmanager and update Panel on this user control, and since then the javascript which selects all the checkboxes is not working properly.

I would like to know what i can do to resolve this javascript issue. And also would like to know why using the basic tools of ASP.NET AJAX control is stopping my own javascript from firing.

Please Note: On leaving a validation on page, the page postback and shows the validation. After this the javascript of Gridview works fine.

I have tried searching on google, but was not able to find any satisfactory explanation to my problem. It would be great if you people can help me.

Thanks,

Shikha

Please post your source code.


Hi,

Thank you for your post!

It is normal when you place inline javascript in an undatepanel/

For more information and solution, seeUpdatePanel and Rendered (Inline)Javascript

It seems that the UpdatePanel essentially replaces the InnerHTML of a DIV with the delta returned from the server. If you try this yourself you will notice that any javascript elements in the html are not fired.

All javascript registered on the server-side (if you are using .NET) with the ScriptManager is put into a separate section of the returned delta. The atlas runtime obviously then loads these scripts into the document manually.

What if the returned HTML has Javascript tags already rendered in it? Nothing.:(
Such was our predicament and we had no control over the HTML that would be returned to the UpdatePanel (ReportViewer Control). Could we manually load the javascript ourselves when the UpdatePanel returns the payload? As it turns, we could.

You can create script elements on the fly and they get evaluated as you do. Atlas has the ScriptLoader object that will do it for you if your JavaScript is an external reference. Tweaking this idea we got a solution that found all the new Script elements and added them to the document.

If you have further questions,let me know.

Best Regards,

Need a way to reemember user selected checkboxes in a gridview in an update panel during a

I'm using ASP.NET 2.0 & Ajax. I have a gridview in an update panel. One of the templated columns in the gridview is a checkbox. In addition, two textboxes provide asynchronous triggers on their "TextChanged" event. I need to remember and re-apply the user selected checkboxes after an asynch postback. I've tried using ViewState as follows:

********************* aspx page code ******************************

<asp:UpdatePanel ID="UpdatePanel1" runat="server" RenderMode="Inline"
OnUnload="GetCheckedStores" OnLoad="SetCheckedStores">
<ContentTemplate>
<asp:Panel ID="StoresPnl" runat="server" Height="50px" Width="608px">
<asp:GridView ID="grvStores" runat="server" AutoGenerateColumns="false" DataMember="DefaultView"
DataSourceID="dsStores" DataKeyNames="Store" EnableTheming="true" Width="400px">
<Columns>
<asp:TemplateField>
<ItemStyle Width="50px" />
<ItemTemplate>
<asp:CheckBox ID="chbStore" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Store" HeaderText="Store #">
<ItemStyle Width="100px" />
</asp:BoundField>
<asp:BoundField DataField="Name" HeaderText="Name">
<ItemStyle Width="150px" />
</asp:BoundField>
<asp:BoundField DataField="BatchCount" HeaderText="Batch Count">
<ItemStyle Width="80px" />
</asp:BoundField>
</Columns>
</asp:GridView>

</asp:Panel>
<!-- ID="StoresPnl" -->
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="txbFromDate" EventName="TextChanged" />
<asp:AsyncPostBackTrigger ControlID="txbToDate" EventName="TextChanged" />
</Triggers>

</asp:UpdatePanel>


******************************* code behind ******************************************

string reportDescription;
string reportCode;
ArrayList checkedStores;

ArrayList CreateCheckedStoresArray()
{
ArrayList result = new ArrayList();
foreach (GridViewRow row in grvStores.Rows)
{
result.Add(false);
}
return result;
}

protected void SetCheckedStores(object sender, EventArgs e)
{
int Ndx = 0;
checkedStores = (ArrayList)ViewState["checkedStoresArray"];

if (checkedStores != null)
{
foreach (GridViewRow row in grvStores.Rows)
{
CheckBox ckbx = row.FindControl("chbStore") as CheckBox;
ckbx.Checked = (bool)checkedStores[Ndx];
Ndx++;
}
}
}

protected void GetCheckedStores(object sender, EventArgs e)
{
int Ndx = 0;
checkedStores = (ArrayList)ViewState["checkedStoresArray"];

if (checkedStores != null)
{
foreach (GridViewRow row in grvStores.Rows)
{
CheckBox ckbx = row.FindControl("chbStore") as CheckBox;
checkedStores[Ndx] = ckbx.Checked;
Ndx++;
}
}
}

protected void Page_PreInit(Object sender, EventArgs e)
{
Page.Theme = Master.Theme;
}

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
checkedStores = CreateCheckedStoresArray();
ViewState.Add("checkedStoresArray", checkedStores);
ReportsPanelVisible();
}
}
*************************************************************************

I was hoping that the "OnLoad" and "OnUnload" attributes of the update panel would execute my code-behind to store/retrieve which checkboxes were checked over an async postback, but this did not work.

I'm not married to this approach, but I do need a clue how to get this done.

Thanks for your help.

To avoid extra effort can you please provide the db related script.


Hi,

If you mean the detailed data source code, data access is done via a Data Access Layer and custom data access objects. I can only post that the DataSourceID="dsStores" is

<mtx:WSDataSource runat="server" ID="dsStores" DataGroup="Report" SubDataGroup="Related">
<SelectParameters>
<asp:ControlParameter ControlID="txbFromDate" Name="DateFrom" PropertyName="Text" />
<asp:ControlParameter ControlID="txbToDate" Name="DateTo" PropertyName="Text" />
</SelectParameters>
</mtx:WSDataSource>

As you can see, this is a custom/propriatary data access. The data returned from this source is quite correct, and the checkbox values are not retrieved from the data base.


Hi,

Based on my understanding, you creat CheckedStoresArray when the gridview is first binded, and then store it in viewstate,when the page is postback,you GetCheckedStores and store them in the Array in viewstate, then update/rebind/change your gridview,then SetCheckedStores according to the value in the array in viewstate.

I think your logic is messed up, just do GetCheckedStores before the gridview rebinding and do SetCheckedStores after the gridview rebinding.

Best Regards

Need an idea for clientside-loaded control container

I am working on an Expandable Row Extender that ideally youwould apply on a gridview (or any other databound control that renders a table)to give it an expandable row functionality. However, I want to do as much aspossible in client side (I've seen the approach of adding an item in thedataset, override onitembound to draw it accordingly and then rebind the datato the control to redraw it, and place it all in an update panel but I don'tlike this approach - obvious reasons). Nor do I like the idea of having every"details" row rendered and hidden.

I kind of like how this feels:http://www.codeproject.com/aspnet/MasterDetail.asp and I very much like how asimilar implementation on www.titlez.com.

That being said, I am trying to make the control as genericas possible (and as easy to use as possible), therefore I think the easiest foranybody to use for the details row would be a usercontrol (so that you can useyour own control, which eventually you might reuse as a webpart as well).

Here is where I need the idea: how to dynamically render thecontrol triggered from the client side (to render it in the expanded row).

The trivial solution would be to use an iframe and load aweb form that would load the control, but there is something that doesn't feelright about this approach.

Any ideas?

I think you can embed user controls to a GridView and implement a inline GridView similar to the demo in www.titlez.com.Besides,maybe a third party user control can be used in a GridView,specially about Chart/Graph controls.
Try to take a look at Ajax website - http://Ajax.asp.net.There are a lot of useful Ajax controltoolkit which can help you to implement it and get a nice web page.

Hi Jasson and thank you for your reply.

I know you can embed user controls in a gridview but what I am trying toachieve is a control that does as much as possible on client side (so when youwould expand a row I wouldn't want to hit the server to add a control in thegrid and rebind the grid, even if this would be in an updatepanel especially asyou might have some time-consuming info in the details row and if you wouldhave several open at the same time this architecture would severely affectperformance. Nor do I want to pre-render everything in one go and initiallyhide the rows for the same reason). Also I am not interested at this time aboutthe graphs and other nice things in those rows, I am just down to the very ideaof the extender control. I am well aware of the ajax controls toolkit and what I am doing isan extender using the same framework, actually extending the extenderbase inthe toolkit.

What I have done so far uses IFrames to render the details row and lets youdefine a usercontrol that will be rendered in the expanded row. It goes througha complicated process of autogenerating a form to host the control at runtime.I was looking for ideas of how to do this without IFrames, using somethingsimilar to an updatepanel that would be able to add the user control atruntime.

Hope this makes sense ..


If you would like to achieve a control as much as possible on the client side,javascript is the unique selection.Ajax control toolkit gives us a good direction to this,however,it can not implement what we need now.I believe it can be done in the near future.I agree with you that if we load too many user controls at runtime in the server side and embed them in a complicated control such as Grivew,DetailsView or FormView,it will affect the server performance. Do you mind MagicAjax which also provides a Ajax framework for us to do further development?MagicAjax is open source and we can extend it to meet our requrements.I don't know if you are inerested in it.

Try to take a look at this reading about MagicAjax for your reference -http://www.c-sharpcorner.com/UploadFile/mosessaur/magicajax02112006060506AM/magicajax.aspx?ArticleID=ddd4757e-7ab7-49da-a3f2-d88b340230c3

Wish this can give you some ideas.


Thanks for sharing the idea. I am afraid I am familiar with MagicAjax as well but I don't see it solving this particular issue. MagicAjax is actiong more like the UpdatePanel control in Ms. Ajax. That wouldn't work without rebinding the grid on the server which wouldn't be any faster. Further more, MagicAjax stores everything on the session so it might bring even more concerns.

Need help adding item from a gridview to a Reorderlist programmically

I have a GridView which I programmically bound to a DataTable.

I also have a ReOrderlist which I've done the same.

I'm trying to have the user click "Add" on the gridview and it adds that row to the Reorderlist.

How can I do I this?


I was trying to pull back out the datasource fom the reorderlist and then add a datarow somehow and then send it back. But I get an object error on that, still working it out.


I'd rather somehow use the .Items.Add(xxx) method, but I don't know how to properly populate it. It wants a RorderListItem, fine, but the ReorderListItem wants a DataItem and I don't know where to get that.

Pretty confused.


Ok I was able to figure it out, I had to reload my datasource on post back before trying it out.

I'd rather do it using Me.QualificationReorderList.Items.Add() somehow, but instead, I pull back the datasource, add a row to it and then re-bind it.

1If e.CommandName.Equals("Add")Then2 Call LoadReorderListItems()34Dim TempReorderListDataTableAs New Data.DataTable5 TempReorderListDataTable =Me.QualificationReorderList.DataSource67Dim TempDataRowAs Data.DataRow89 TempDataRow = TempReorderListDataTable.NewRow1011 TempDataRow.Item("CERTIFICATION_ID") = 123412 TempDataRow.Item("CERTIFICATION_TITLE") ="12"13 TempDataRow.Item("DISPLAY_ORDER") = 01415 TempReorderListDataTable.Rows.Add(TempDataRow)1617Me.QualificationReorderList.DataSource = TempReorderListDataTable18Me.QualificationReorderList.DataBind()19End If

Wednesday, March 21, 2012

Need more info than args.get_postBackElement().id

The gridview has Edit option on each row and pages at the bottom for paging.

For paging, I just refresh the current gridview (UpdatePanel) with content of the next page.

For edit, I need to load the content of a row into a separate UpdatePanel.

The mouseover of edit & paging show the same elements

__doPostBack('ctl00$ContentPlaceHolder1$grdEvents','LoadEdit$0')

__doPostBack('ctl00$ContentPlaceHolder1$grdEvents','Page$0')

I need to be able to access the variable that contains the second parameter LoadEdit$0/Page$0 to distinguish which action and turn on the coressponding indicator.

Hi,

<inputtype="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" /><input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />function __doPostBack(eventTarget, eventArgument) {if (!theForm.onsubmit || (theForm.onsubmit() != false)) {theForm.__EVENTTARGET.value = eventTarget;theForm.__EVENTARGUMENT.value = eventArgument;theForm.submit();}}

Analysis

The __doPostBack function takes two arguments, eventTarget and eventArgument. The eventTarget contains the ID of the control that causes the postback and the eventArgument contains any additional data associated with the control. Note that the two hidden fields, "__EVENTTARGET" and "__EVENTARGUMENT," are automatically declared. The value of the eventTarget and eventArgument are stored in the hidden fields. The two hidden variables can be accessed from the code behind using the forms/params collection.

Using the hidden variables you can also find the ID of the control which causes the postback. All you need to do is to retrieve the value of the __EVENTTARGET from the form parameter collection. Take a look at the code below.

Listing 2 – Getting the _EVENTTARGET hidden field

protected void Page_Load(object sender, EventArgs e){  string controlName = Request.Params.Get("__EVENTTARGET");}
The same to eventArgument!
Best Regards,