Click here to Skip to main content
15,907,906 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
i m using 5 ajax ModalPopupExtender

in gridview there is view image button and i want to open
ModalPopupExtender conditionaly .In my gridview its bound with table of sqlserver there is 1st col of Id and I want to open respective
ModalPopupExtender according to id
(eg) if id is 1 then open Ist ModalPopupExtender and
Id=2 open 2nd ModalPopupExtender and so on

here is my code




XML
<cc1:TabPanel ID="tabBenefits" runat="server" HeaderText="Benefits" Height="500%">
         <ContentTemplate>
             
             <table id="tblBeneFits" cellpadding="3px">
                 <tr>
                     <td>
                         <asp:Label ID="lblBenefitType" runat="server" Text="Benefit Type"></asp:Label>
                     </td>
                     
                     <td>
                     
                         <asp:DropDownList ID="ddlBenefitTypes" runat="server" Width="200px" 
                          onchange="ddl_change();">
                         </asp:DropDownList>
                     </td>
                     <td>
                         <asp:Button ID="btnAddVehicle" runat="server" Text="Add" CssClass="btns"/>
                         <asp:Button ID="btnAddFuel" runat="server"    Text="Add" CssClass="btns"/>
                         <asp:Button ID="btnAddVMT" runat="server"     Text="Add" CssClass="btns"/>
                         <asp:Button ID="btnAddMobile" runat="server"     Text="Add" CssClass="btns"/>
                         <asp:Button ID="btnAddMAT" runat="server"     Text="Add" CssClass="btns"/>
                     </td>
                 </table>
                 <div style="padding-top:20px;padding-left:20px;">
                     <asp:GridView ID="gv_Benefit" runat="server" AutoGenerateColumns="false"
                      EmptyDataRowStyle-BorderWidth="2px" EmptyDataRowStyle-HorizontalAlign="Center"
                      onrowcommand="gv_Benefit_RowCommand" onrowdatabound="gv_Benefit_RowDataBound"
                       EmptyDataText="No Record Found">
                         <AlternatingRowStyle BackColor="#6699FF" />
                         <Columns>
                         <asp:BoundField DataField="Id" HeaderText="Id" HeaderStyle-Width="30px" ItemStyle-Width="30px">
                         </asp:BoundField>
                         <asp:BoundField DataField="Benefit" HeaderText="BeneFit" HeaderStyle-Width="250px" ItemStyle-Width="250px">
                         </asp:BoundField>
                         <asp:BoundField DataField="Benefittype" HeaderText="Type" HeaderStyle-Width="150px" ItemStyle-Width="150px">
                         </asp:BoundField>
                         <asp:BoundField DataField="IssuedDate"  HeaderText="Start Date" DataFormatString="{0:d}" HeaderStyle-Width="90px" ItemStyle-Width="90px">
                         </asp:BoundField>
                         <asp:BoundField DataField="ReturnDate"  HeaderText="End Date" DataFormatString="{0:d}" HeaderStyle-Width="90px" ItemStyle-Width="90px">
                         </asp:BoundField>
                         
                         <asp:TemplateField HeaderText="view" ShowHeader="False">
                         <ItemTemplate>
                         <asp:ImageButton ID="gvben_btnview" runat="server" CommandName="gvben_cmdview" 
                         ImageUrl="~/Images/UserGroups_Head.gif" ToolTip="click" />
                         </ItemTemplate>
                         <HeaderStyle Width="30px" />
                         <ItemStyle Width="30px" />
                         </asp:TemplateField>
                         
                         
                         <asp:TemplateField HeaderText="Remove" ShowHeader="False">
                         <ItemTemplate>
                         <asp:ImageButton ID="gvben_btndelete" runat="server" CommandName="gvben_cmddelete" 
                          ImageUrl="~/Images/Cancel.gif" ToolTip="click" />
                         </ItemTemplate>
                         <HeaderStyle Width="30px" />
                         <ItemStyle Width="30px" />
                         </asp:TemplateField>
                    
                         </Columns> 
                     </asp:GridView>
                 </div>
                         
                   
                    <%--   <cc1:ModalPopupExtender ID="mdlVehicle" runat="server" 
                             TargetControlID="btnAddVehicle"
                             PopupControlID="pnlBenefit_Vehicle"
                             CancelControlID="btnvehicle_Cancel"
                             DropShadow="true">
                         </cc1:ModalPopupExtender>--%>
                         
                         <cc1:ModalPopupExtender ID="mdlFuel" runat="server" 
                             TargetControlID="btnAddFuel"
                             PopupControlID="pnlBenefitsFuel"
                             CancelControlID="btnFuelCancel"
                             DropShadow="true">
                         </cc1:ModalPopupExtender>
                         
                         <cc1:ModalPopupExtender ID="ModalPopupExtender1" runat="server" 
                             TargetControlID="btnAddVMT"
                             PopupControlID="pnlVehicleMaintainceAllowence"
                             CancelControlID="btnVMT_Cancel"
                             DropShadow="true">
                         </cc1:ModalPopupExtender>
                         
                           <cc1:ModalPopupExtender ID="ModalPopupExtender2" runat="server" 
                             TargetControlID="btnAddMobile"
                             PopupControlID="pnlCellPhone"
                             CancelControlID="btnMobileCancel"
                             DropShadow="true">
                         </cc1:ModalPopupExtender>
                         
                         <cc1:ModalPopupExtender ID="ModalPopupExtender3" runat="server" 
                             TargetControlID="btnAddMAT"
                             PopupControlID="pnlMobileAllowenceType"
                             CancelControlID="btnMATCancel"
                             DropShadow="true">
                         </cc1:ModalPopupExtender>
                         
                         
                 <asp:Panel ID="pnlBenefit_Vehicle" runat="server"  Width="700px" Height="300px" BackColor="WhiteSmoke">
                      <div id="div9" style="padding-left:20px;padding-top:30px;">
                         <table border="1px">
                         <tr>
                         <td colspan="6">
                         <asp:Label ID="lblHeading" runat="server" Font-Bold="true" Font-Size="Large" 
                         Text="Vehicle"></asp:Label>
                         </td>
                         </tr>
                         <tr>
                         <td>
                         <asp:Label ID="Label8" runat="server" Text="Make"></asp:Label>
                         </td>
                         <td class="style2">
                             <asp:DropDownList ID="ddlVehicle_VehicleMake" runat="server" Width="150px"></asp:DropDownList>
                         </td>
                         <td>
                         <asp:Label ID="Label2" runat="server" Text="Model"></asp:Label>
                         </td>
                         <td>
                         <asp:TextBox ID="txtModel" runat="server"></asp:TextBox>
                         </td>
                         </tr>
                         <tr>
                         <td>
                         <asp:Label ID="Label4" runat="server" Text="Reg No"></asp:Label>
                         </td>
                         <td>
                         <asp:TextBox ID="txtRegNo" runat="server"></asp:TextBox>
                         </td>
                         <td>
                         <asp:Label ID="Label9" runat="server" Text="Reg Year"></asp:Label>
                         </td>
                         <td>
                             <asp:DropDownList ID="ddlVehicle_RegYear" runat="server" Width="150px"></asp:DropDownList>
                         </td>
                         </tr>
                         <tr>
                         <td>
                         <asp:Label ID="Label5" runat="server" Text="Color"></asp:Label>
                         </td>
                         <td>
                         <asp:TextBox ID="txtVehiclecolor" runat="server"></asp:TextBox>
                         </td>
                         <td>
                         <asp:Label ID="Label6" runat="server" Text="Engine Size"></asp:Label>
                         </td>
                         <td>
                         <asp:TextBox ID="txtEngineSize" runat="server"></asp:TextBox>
                         </td>
                         <tr>
                          <td>
                                <asp:Label ID="Label27" runat="server" Text="Reg Date"></asp:Label>
                             </td>
                             
                             <td>
                                 
                                  <asp:TextBox ID="txtRegDate" runat="server"></asp:TextBox>
                                   <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ErrorMessage="Date Req" SetFocusOnError="true"
                                     Font-Bold="true" ForeColor="Red" ControlToValidate="txtRegDate" 
                                     ValidationGroup="gp_vehicle"></asp:RequiredFieldValidator>
                                     <img id="Img2" alt="click" height="21" src="../Images/calender.gif" 
                                     width="22" />     
                                     <cc1:CalendarExtender ID="CalendarExtender6" runat="server" Format="dd/MM/yyyy"
                                     TargetControlID="txtRegDate" PopupButtonID="Img2" OnClientShown="calendarShown">
                                     </cc1:CalendarExtender>
                             
                             
                             </td>
                         
                         </tr>
                         <tr>
                             <td>
                                 <asp:Label ID="lblVehicleStartDate" runat="server" Text="Start Date"></asp:Label>
                             </td>
                             <td>
                                 <asp:TextBox ID="txtVehicle_StartDate" runat="server"></asp:TextBox>
                                     <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ErrorMessage="Date Req" SetFocusOnError="true"
                                     Font-Bold="true" ForeColor="Red" ControlToValidate="txtVehicle_StartDate" 
                                     ValidationGroup="gp_vehicle"></asp:RequiredFieldValidator>
                                     <img id="vehiclestartdate" alt="click" height="21" src="../Images/calender.gif" 
                                     width="22" />     
                                     <cc1:CalendarExtender ID="CalendarExtender2" runat="server" Format="dd/MM/yyyy"
                                     TargetControlID="txtVehicle_StartDate" PopupButtonID="vehiclestartdate" OnClientShown="calendarShown">
                                     </cc1:CalendarExtender>
                             </td>
                             <td>
                                <asp:Label ID="Label1" runat="server" Text="End Date"></asp:Label>
                             </td>
                             
                             <td>
                                 
                                  <asp:TextBox ID="txtvehicleEndDate" runat="server"></asp:TextBox>
                                   <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Date Req" SetFocusOnError="true"
                                     Font-Bold="true" ForeColor="Red" ControlToValidate="txtvehicleEndDate" 
                                     ValidationGroup="gp_vehicle"></asp:RequiredFieldValidator>
                                     <img id="Img1" alt="click" height="21" src="../Images/calender.gif" 
                                     width="22" />     
                                     <cc1:CalendarExtender ID="CalendarExtender3" runat="server" Format="dd/MM/yyyy"
                                     TargetControlID="txtvehicleEndDate" PopupButtonID="Img1" OnClientShown="calendarShown">
                                     </cc1:CalendarExtender>
                             
                             
                             </td>
                         
                         </tr>
                         </tr>
                         <tr>
                             <td>
                             <asp:Label ID="lblVehicleDesc" runat="server" Text="Description"></asp:Label>
                             </td>
                             <td>
                                 <asp:TextBox ID="txtVehicleDesc" runat="server" TextMode="MultiLine"></asp:TextBox>
                                 </td>
                         </tr>
                         <tr>
                             <td>
                              <asp:Button ID="btnvehicle_save" runat="server" Text="Save" ValidationGroup="gp_vehicle"
                               CssClass="btns" OnClick="btnvehicle_save_Click" />     
                             </td>
                             <td>
                               <asp:Button ID="btnvehicle_Cancel" runat="server" Text="Cancel"  Width="60" CssClass="btns" />
                             </td>
                         
                         </tr>

                         </table>
                     </div>
                 
     </asp:Panel>
                     
         </ContentTemplate>
     </cc1:TabPanel>
                     <asp:Panel ID="pnlBenefitsFuel" runat="server" Height="300px" Width="700px" BackColor="WhiteSmoke">
                      <div id="div10" style="padding-left:20px;padding-top:30px;">
                     <table  border="1px">
                     <tr>
                      <td colspan="6">
                    
                     <asp:Label ID="lblFuelHeading" runat="server" Font-Bold="True" Font-Size="Large" 
                     Text="Fuel"></asp:Label>
                    </td>
                     </tr>
                     <tr>
                     <td>
                     <asp:Label ID="lblCardNO" runat="server" Text="Card No"></asp:Label>
                     </td>
                     <td>
                         <asp:TextBox ID="txtCardNo" runat="server"></asp:TextBox>
                     </td>
                     </tr>
                     <tr>
                     <td>
                          <asp:Label ID="Label10" runat="server" Text="Vehicle Type"></asp:Label>
                     </td>
                     <td>
                           <asp:DropDownList ID="ddlVehicletype" runat="server" Width="100px">
                             <asp:ListItem Text="Car" Value="car">
                             </asp:ListItem>
                             <asp:ListItem Text="Motor cycle" Value="Motor cycle">
                             </asp:ListItem>
                             
                         </asp:DropDownList>
                     </td>
                     
                     <td>
                              <asp:Label ID="Label11" runat="server" Text="Vehicle No"></asp:Label>
                     </td>
                     <td>
                         <asp:TextBox ID="txtVehicleNo" runat="server"></asp:TextBox>
                     </td>
                   
                     </tr>
                     <tr>
                     <td>
                     <asp:Label ID="lblFuelLimit" runat="server" Text="Fuel Limit"></asp:Label>
                     </td>
                     <td>
                     <asp:TextBox ID="txtFuelLimit" runat="server"></asp:TextBox>
                     </td>
                     <td>
                     <asp:Label ID="Label13" runat="server" Text="Cng Limit"></asp:Label>
                     </td>
                     <td>
                     <asp:TextBox ID="txtcngLimit" runat="server"></asp:TextBox>
                     </td>
                     </tr>
                     <tr>
                     <td>
                     <asp:Label ID="Label14" runat="server" Text="Start Date"></asp:Label>
                     </td>
                     <td>
                     <asp:TextBox ID="txtFuel_StartDate" runat="server"></asp:TextBox>
                     
                      <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="Date Req" SetFocusOnError="true"
                     Display="Static" Font-Bold="true" ForeColor="Red" ControlToValidate="txtFuel_StartDate"
                     ValidationGroup="gp_Fuel"></asp:RequiredFieldValidator>
                     <img id="imgValidFrom" alt="click" height="21" src="../Images/calender.gif" 
                     width="22" />   
                     <cc1:CalendarExtender ID="CalendarExtender4" runat="server" Format="dd/MM/yyyy"
                     TargetControlID="txtFuel_StartDate" PopupButtonID="imgValidFrom" OnClientShown="calendarShown">
                     </cc1:CalendarExtender>
                     
                     </td>
                     <td>
                     <asp:Label ID="Label15" runat="server" Text="End Date"></asp:Label>
                     </td>
                     <td>
                     <asp:TextBox ID="txtFuel_Enddate" runat="server"></asp:TextBox>
                     
                       <asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" ErrorMessage="Date Req" SetFocusOnError="true"
                     Display="Static" Font-Bold="true" ForeColor="Red" ControlToValidate="txtFuel_Enddate"
                     ValidationGroup="gp_Fuel"></asp:RequiredFieldValidator>
                     <img id="imgvalidto" alt="click" height="21" src="../Images/calender.gif" 
                     width="22" />   
                     <cc1:CalendarExtender ID="CalendarExtender5" runat="server" Format="dd/MM/yyyy"
                     TargetControlID="txtFuel_Enddate" PopupButtonID="imgvalidto" OnClientShown="calendarShown">
                     </cc1:CalendarExtender>
                     </td>

                     </tr>
                     <tr>
                     <td>
                     </td>
                     </tr>
                     <tr>
                     <td>
                     <asp:Label ID="Label12" runat="server" Text="Description"></asp:Label>
                     </td>
                     <td>
                     <asp:TextBox ID="txtFuel_Description" TextMode="MultiLine" Width="200px"
                     MaxLength="100" runat="server"></asp:TextBox>
                     </td>
                     </tr>
                     <tr>
                         <td>
                             <asp:Button ID="btnFuelSave" runat="server" Text="Save" CssClass="btns" ValidationGroup="gp_Fuel" 
                             OnClick="btnFuelSave_Click"/>
                         </td>
                         <td>
                          <asp:Button ID="btnFuelCancel" runat="server" Text="Cancel" Width="60px" CssClass="btns" />
                         </td>
                     
                     </tr>                       
                    
                     
                     
                    
                     </table>
                     </div>
                     </asp:Panel>
                     <asp:Panel ID="pnlVehicleMaintainceAllowence" runat="server" Width="700px" Height="300" BackColor="WhiteSmoke">
                         <div id="div11" style="padding-left:20px;padding-top:30px;">
                         <table id="tblVMA" border="1px" cellpadding="3px">
                         <tr>
                         
                               <asp:Label ID="lblMVAHEading" runat="server" Text="Vehicle Maintaince Allowence" Font-Size="Large"></asp:Label>
                         </tr>
                         
                         <tr>
                             <td>
                             
                                  <asp:Label ID="lblvmt" runat="server" Text="Type"></asp:Label>
                             </td>
                             <td colspan="50px">
                                 <asp:DropDownList ID="ddlMVT_MaintainceType" runat="server" Width="150px"></asp:DropDownList>
                             </td>
                         </tr>
                         <tr>
                             <td>
                              <asp:Label ID="Label3" runat="server" Text="Amount"></asp:Label>
                                 
                             </td>
                             <td>
                                 <asp:TextBox ID="txtVMT_Amount" runat="server"></asp:TextBox>
                             </td>
                         </tr>
                         <tr>
                        
                             <td>
                                  <asp:Label ID="Label7" runat="server" Text="Start date"></asp:Label>
                             
                             </td>
                             <td>
                                  <asp:TextBox ID="txtVMT_Startdate" runat="server"></asp:TextBox>
                            
                                  <asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server" ErrorMessage="Date Req" SetFocusOnError="true"
                     Display="Static" Font-Bold="true" ForeColor="Red" ControlToValidate="txtVMT_Startdate" ValidationGroup="gp_VMT"></asp:RequiredFieldValidator>
                     <img id="imgVMTStartDate" alt="click" height="21" src="../Images/calender.gif" 
                     width="22" />   
                     <cc1:CalendarExtender ID="CalendarExtender8" runat="server" Format="dd/MM/yyyy"
                     TargetControlID="txtVMT_Startdate" PopupButtonID="imgVMTStartDate" OnClientShown="calendarShown">
                     </cc1:CalendarExtender>
                             </td>
                             <td>
                             <asp:Label ID="Label16" runat="server" Text="End Date"></asp:Label>
                             
                             </td>
                             <td>
                                  <asp:TextBox ID="txtVMT_Enddate" runat="server"></asp:TextBox>
                                  
                                      <asp:RequiredFieldValidator ID="RequiredFieldValidator8" runat="server" ErrorMessage="Date Req" SetFocusOnError="true"
                     Display="Static" Font-Bold="true" ForeColor="Red" ControlToValidate="txtVMT_Enddate" ValidationGroup="gp_VMT"></asp:RequiredFieldValidator>
                     <img id="imgVMTEndadte" alt="click" height="21" src="../Images/calender.gif" 
                     width="22" />   
                     <cc1:CalendarExtender ID="CalendarExtender9" runat="server" Format="dd/MM/yyyy"
                     TargetControlID="txtVMT_Enddate" PopupButtonID="imgVMTEndadte" OnClientShown="calendarShown">
                     </cc1:CalendarExtender>
                             </td>
                         </tr>
                         <tr>
                             <td>
                             
                                 <asp:Label ID="Label17" runat="server" Text="Description"></asp:Label>
                             </td>
                             <td>
                                 <asp:TextBox ID="txtVMTDesc" runat="server" TextMode="MultiLine"></asp:TextBox>
                             </td>
                             
                         
                         </tr>
                         <tr>
                             <td>
                                 <asp:Button ID="btnVMTSave" runat="server" Text="Save" CssClass="btns" ValidationGroup="gp_VMT"  OnClick="btnVMTSave_Click" />

                             </td>
                             <td>
                                   <asp:Button ID="btnVMT_Cancel" runat="server" Text="Cancel" Width="60px" CssClass="btns" />
                             </td>
                         
                         </tr>
                         </table>
                         </div>
                     </asp:Panel>
                     <asp:Panel ID="pnlCellPhone" runat="server" Height="300px" BackColor="WhiteSmoke">
                         <div id="div12" style="padding-left:20px;padding-top:30px;">
                         <table border="1px" cellpadding="3px">
                             <tr>
                                 <asp:Label ID="lbiMobile" runat="server" Text="Mobile"></asp:Label>
                                 
                             </tr>
                             <tr>
                                 <td>
                                     <asp:Label ID="Label18" runat="server" Text="Set"></asp:Label>
                                 </td>
                                 <td>
                                     <asp:DropDownList ID="ddlmobile" runat="server" Width="150px"></asp:DropDownList>
                                 </td>
                             </tr>
                             <tr>
                                 <td>
                                     <asp:Label ID="Label19" runat="server" Text="Imei #"></asp:Label>
                                 </td>
                                 <td>
                                     <asp:TextBox ID="txtimeino" runat="server"></asp:TextBox>
                                 </td>
                                 <td>
                                     <asp:Label ID="Label20" runat="server" Text="Color"></asp:Label>
                                 </td>
                                 <td>
                                     <asp:TextBox ID="txtcolor" runat="server"></asp:TextBox>
                                 </td>
                             
                             </tr>
                              <tr>
                        
                             <td>
                                  <asp:Label ID="Label21" runat="server" Text="Warranty Start date"></asp:Label>
                             
                             </td>
                             <td>
                                  <asp:TextBox ID="txtMobileStartDate" runat="server"></asp:TextBox>
                            
                                  <asp:RequiredFieldValidator ID="RequiredFieldValidator9" runat="server" ErrorMessage="Date Req" SetFocusOnError="true"
                     Display="Static" Font-Bold="true" ForeColor="Red" ControlToValidate="txtMobileStartDate" ValidationGroup="gp_Mobile"></asp:RequiredFieldValidator>
                     <img id="imgMobileStartDate" alt="click" height="21" src="../Images/calender.gif" 
                     width="22" />   
                     <cc1:CalendarExtender ID="CalendarExtender10" runat="server" Format="dd/MM/yyyy"
                     TargetControlID="txtMobileStartDate" PopupButtonID="imgMobileStartDate" OnClientShown="calendarShown">
                     </cc1:CalendarExtender>
                             </td>
                             <td>
                             <asp:Label ID="Label22" runat="server" Text="Warranty End Date"></asp:Label>
                             
                             </td>
                             <td>
                                  <asp:TextBox ID="txtMobileEnddate" runat="server"></asp:TextBox>
                                  
                                      <asp:RequiredFieldValidator ID="RequiredFieldValidator10" runat="server" ErrorMessage="Date Req" SetFocusOnError="true"
                     Display="Static" Font-Bold="true" ForeColor="Red" ControlToValidate="txtMobileEnddate" ValidationGroup="gp_Mobile"></asp:RequiredFieldValidator>
                     <img id="imgMobileEnddate" alt="click" height="21" src="../Images/calender.gif" 
                     width="22" />   
                     <cc1:CalendarExtender ID="CalendarExtender11" runat="server" Format="dd/MM/yyyy"
                     TargetControlID="txtMobileEnddate" PopupButtonID="imgMobileEnddate" OnClientShown="calendarShown">
                     </cc1:CalendarExtender>
                             </td>
                         </tr>
                         <tr>
                             <td>
                                 <asp:Label ID="lblMobileDesc" runat="server" Text="Description"></asp:Label>
                             </td>
                             <td>
                                 <asp:TextBox ID="txtMobileDesc" runat="server" TextMode="MultiLine"></asp:TextBox>
                             </td>
                         
                         </tr>
                           <tr>
                             <td>
                                  <asp:Button ID="btnMobileSave" runat="server" Text="save" ValidationGroup="gp_Mobile"  CssClass="btns"  OnClick="btnMobileSave_Click"/>
                             </td>
                             <td>
                                 
                                  <asp:Button ID="btnMobileCancel" runat="server" Text="Cancel" Width="60px" CssClass="btns" />
                             </td>
                         
                         </tr>
                             
                         </table>
                         </div>
                     </asp:Panel>
                     <asp:Panel ID="pnlMobileAllowenceType" runat="server" Width="700px" Height="300px" BackColor="WhiteSmoke">
                     <div id="divMAT" style="padding-left:20px;padding-top:30px;">
                         <table id="tblMAT" border="1px" cellpadding="3px">
                             <tr>
                                 
                                 <asp:Label ID="lblHeadingMAT" runat="server" Text="Mobile Allowence" Font-Size="Large"></asp:Label>
                                 
                             </tr>
                             <tr>
                                 <td>
                                     <asp:Label ID="Label23" runat="server" Text="Type"></asp:Label>
                                 
                                 </td>
                                 <td>
                                     <asp:DropDownList ID="ddlMAT_Type" runat="server" Width="150px"></asp:DropDownList>
                                 
                                 </td>
                             
                             </tr>
                             <tr>
                                 <td>
                                     <asp:Label ID="Label24" runat="server" Text="Amount"></asp:Label>
                                 </td>
                                 <td>
                                     <asp:TextBox ID="txtMATAmount" runat="server"></asp:TextBox>
                                 </td>
                                 
                             </tr>
                              <tr>
                        
                             <td>
                                  <asp:Label ID="Label25" runat="server" Text="Start date"></asp:Label>
                             
                             </td>
                             <td>
                                  <asp:TextBox ID="txtMATstartDate" runat="server"></asp:TextBox>
                            
                                  <asp:RequiredFieldValidator ID="RequiredFieldValidator11" runat="server" ErrorMessage="Date Req" SetFocusOnError="true"
                     Display="Static" Font-Bold="true" ForeColor="Red" ControlToValidate="txtMATstartDate" ValidationGroup="gp_MAT"></asp:RequiredFieldValidator>
                     <img id="imgMobileStart" alt="click" height="21" src="../Images/calender.gif" 
                     width="22" />   
                     <cc1:CalendarExtender ID="CalendarExtender12" runat="server" Format="dd/MM/yyyy"
                     TargetControlID="txtMATstartDate" PopupButtonID="imgMobileStart"  OnClientShown="calendarShown">
                     </cc1:CalendarExtender>
                             </td>
                             <td>
                             <asp:Label ID="Label26" runat="server" Text="End Date"></asp:Label>
                             
                             </td>
                             <td>
                                  <asp:TextBox ID="txtMATenddate" runat="server"></asp:TextBox>
                                  
                                      <asp:RequiredFieldValidator ID="RequiredFieldValidator12" runat="server" ErrorMessage="Date Req" SetFocusOnError="true"
                     Display="Static" Font-Bold="true" ForeColor="Red" ControlToValidate="txtMATenddate" ValidationGroup="gp_MAT"  ></asp:RequiredFieldValidator>
                     <img id="imgMATenddate" alt="click" height="21" src="../Images/calender.gif" 
                     width="22" />   
                     <cc1:CalendarExtender ID="CalendarExtender13" runat="server" Format="dd/MM/yyyy"
                     TargetControlID="txtMATenddate" PopupButtonID="imgMATenddate" OnClientShown="calendarShown">
                     </cc1:CalendarExtender>
                             </td>
                         </tr>
                         <tr>
                             <td>
                                 <asp:Label ID="lblMatDesc" runat="server" Text="Description"></asp:Label>
                             </td>
                             <td>
                                 <asp:TextBox ID="txtMATDesc" runat="server" TextMode="MultiLine"></asp:TextBox>
                             </td>
                         
                         </tr>
                             <tr>
                             <td>
                                  <asp:Button ID="btnMATSave" runat="server" Text="save"  CssClass="btns" ValidationGroup="gp_MAT" OnClick="btnMATSave_Click" />
                             </td>
                             <td>
                                 
                                  <asp:Button ID="btnMATCancel" runat="server" Text="Cancel" Width="60px" CssClass="btns" />
                             </td>
                         
                         </tr>
                         
                         </table>
                     </div>
                     </asp:Panel>



C#
function ddl_change() {


             var val = document.getElementById('MainContent_TabContainer1_tabBenefits_ddlBenefitTypes').value;

             var vehicle = 'MainContent_TabContainer1_tabBenefits_btnAddVehicle';
             var fuel = 'MainContent_TabContainer1_tabBenefits_btnAddFuel';
             var vma = 'MainContent_TabContainer1_tabBenefits_btnAddVMT';
             var mobile = 'MainContent_TabContainer1_tabBenefits_btnAddMobile'
             var ma = 'MainContent_TabContainer1_tabBenefits_btnAddMAT';



             switch (val) {

                 case '1':
                     document.getElementById(vehicle).style.display = 'block';
                     document.getElementById(fuel).style.display = 'none';
                     document.getElementById(vma).style.display = 'none';
                     document.getElementById(mobile).style.display = 'none';
                     document.getElementById(ma).style.display = 'none';

                     break;

                 case '2':

                     document.getElementById(vehicle).style.display = 'none';
                     document.getElementById(fuel).style.display = 'block';
                     document.getElementById(vma).style.display = 'none';
                     document.getElementById(mobile).style.display = 'none';
                     document.getElementById(ma).style.display = 'none';
                     break;

                 case '3':
                     document.getElementById(vehicle).style.display = 'none';
                     document.getElementById(fuel).style.display = 'none';
                     document.getElementById(vma).style.display = 'block';
                     document.getElementById(mobile).style.display = 'none';
                     document.getElementById(ma).style.display = 'none';
                     break;



                 case '4':

                     document.getElementById(vehicle).style.display = 'none';
                     document.getElementById(fuel).style.display = 'none';
                     document.getElementById(vma).style.display = 'none';
                     document.getElementById(mobile).style.display = 'block';
                     document.getElementById(ma).style.display = 'none';
                     break;

                 case '5':
                     document.getElementById(vehicle).style.display = 'none';
                     document.getElementById(fuel).style.display = 'none';
                     document.getElementById(vma).style.display = 'none';
                     document.getElementById(mobile).style.display = 'none';
                     document.getElementById(ma).style.display = 'block';
                     break;

                 default:
                     alert('out');
                     break;

             }
         }


help me :sigh:
Posted

1 solution

During ItemDataBound event of grid, based on the row number you can play along with your logic of odd or even. Accordingly add the method to the image button to open the respective modal popup.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900