Results 1 to 7 of 7

Thread: ajax and gridview

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2007
    Location
    Karachi
    Posts
    551

    ajax and gridview

    see the follwoing code

    Code:
    <div class="right_txt_space_accm">
        
    											<table width="100%" border="0" cellspacing="0" cellpadding="0">
    											  <tr>
    											  <td align=left width="100%">
                                                      <asp:GridView  AllowPaging=True   ID="GridView1" runat="server" 
                                                          DataSourceID=SqlDataSource1  DataKeyNames=userid  
                                                          AutoGenerateColumns="False" BackColor="White" 
                                                          BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" CellPadding="3" 
                                                          Width="449px" style="margin-right: 0px" PageSize="11">
                                                      <RowStyle ForeColor="#000066" />
                                                          <Columns>
                                                              <asp:BoundField DataField="userid" HeaderText="ID" ReadOnly="True" 
                                                                  SortExpression="userid" />
                                                              <asp:BoundField DataField="Name" HeaderText="Name" ReadOnly="True" 
                                                                  SortExpression="Name" />
                                                                    <asp:BoundField DataField="Position" HeaderText="Position" ReadOnly="True" 
                                                                  SortExpression="Position" />
                                                              <asp:CommandField   HeaderText="Select User" ShowHeader="True" 
                                                                  ShowSelectButton="True"  />
                                                                  <asp:TemplateField HeaderText="GFLN Member Available">
        <ItemTemplate>
            <asp:CheckBox ID="chkgfln" Enabled=false runat="server" Checked='<%# Bind("GFLN_Membership") %>' />
           
        </ItemTemplate>
           
    </asp:TemplateField>
      
          <asp:TemplateField HeaderText="Approve">
        <ItemTemplate>
             <asp:CheckBox ID="CheckBox1" Enabled=true runat="server" Checked=false />
            
        </ItemTemplate>
           
    </asp:TemplateField>
      
    
                                                           
                                                          </Columns>
               <FooterStyle BackColor="White" ForeColor="#000066" />
                  <PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" />
                  
                  <HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />
    
            </asp:GridView>
           
         
           
         
            								          <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                                                          ConnectionString="<%$ ConnectionStrings:reniConnectionString %>" 
                                                           SelectCommand="SELECT * FROM [Users]" ></asp:SqlDataSource>      
                 								  </td>
    												 </tr>
    	</table>
    	</div>
    	
    	<div visible=true runat=server id=details class="right_txt_space_accm">
    	
    	<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode=conditional>
    
    <ContentTemplate>
    	<table width="100%" border="0" cellspacing="0" cellpadding="0">
    	<tr>
    	<td><strong>Companies </strong></td>
    	</tr>
    											  <tr>
    											  <td align=left width="100%">
                                                      <asp:GridView ID="GridView2" runat="server" Width="286px">
                                                      </asp:GridView>
                                                  </td> </tr> </table> 
                                                   </ContentTemplate> 
                                               
                                                 
                                                 
                                                      <Triggers>
                                               <asp:AsyncPostBackTrigger ControlID="GridView1" EventName="SelectedIndexChanged" />
                                               </Triggers>
                                                  </asp:UpdatePanel> 
    											  
    	</div>
    but i m getting an exception when page(paging) is changed


    Sys.WebForms.PageRequestManagerServerErrorException: Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback
    There is no achievement without goals

  2. #2
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: ajax and gridview

    Within your GridView, what are you actually doing, i.e. what button/control are you interacting with that causes the postback, and ultimately the exception?

    Gary

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2007
    Location
    Karachi
    Posts
    551

    Re: ajax and gridview

    when i changed pageindexing say pagesize is 10 and when i move to next page it causes this exception
    There is no achievement without goals

  4. #4
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: ajax and gridview

    Yes, but how exactly are you moving to the next page? I don't see anything in the markup that you posted that would allow page navigation, and I don't see that you have set the AllowPaging Property of the GridView, which would create this UI for you.

    Gary

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2007
    Location
    Karachi
    Posts
    551

    Re: ajax and gridview

    Code:
    <asp:GridView  AllowPaging=True   ID="GridView1" runat="server" 
                                                          DataSourceID=SqlDataSource1  DataKeyNames=userid  
                                                          AutoGenerateColumns="False" BackColor="White" 
                                                          BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" CellPadding="3" 
                                                          Width="449px" style="margin-right: 0px"  PageSize="10">
                                                      <RowStyle ForeColor="#000066" />
                                                          <Columns>
                                                              <asp:BoundField DataField="userid" HeaderText="ID" ReadOnly="True" 
                                                                  SortExpression="userid" />
                                                              <asp:BoundField DataField="Name" HeaderText="Name" ReadOnly="True" 
                                                                  SortExpression="Name" />
                                                                   <asp:BoundField DataField="Email" HeaderText="email" ReadOnly="True" 
                                                                  SortExpression="email" />
                                                                    <asp:BoundField DataField="Position" HeaderText="Position" ReadOnly="True" 
                                                                  SortExpression="Position" />
                                                              <asp:CommandField   HeaderText="Select User" ShowHeader="True" 
                                                                  ShowSelectButton="True"  />
                                                                  
                                                                  <asp:TemplateField HeaderText="GFLN MemberShip">
        <ItemTemplate>
            <asp:CheckBox ID="chkgfln" Enabled=false runat="server" Checked='<%# Bind("GFLN_Membership") %>' />
           
        </ItemTemplate>
           
    </asp:TemplateField>
        <asp:TemplateField HeaderText="Company details">
        <ItemTemplate>
        <asp:Button ID="btnViewDetails" runat="server" Text="Details" OnClick="BtnViewDetails_Click" OnClientClick=true />
       <asp:ModalPopupExtender ID="mdlPopup" runat="server" TargetControlID="btnViewDetails" PopupControlID="pnlPopup" 
                    CancelControlID="btnClose" BackgroundCssClass="modalBackground" />
       
        </ItemTemplate>
       
          
    
        
       </asp:TemplateField>
         <asp:TemplateField HeaderText="Want Visa">
        <ItemTemplate>
            <asp:CheckBox ID="chkvisa" Enabled=false runat="server" Checked='<%# Bind("want_visa") %>' />
           
        </ItemTemplate>
           
    </asp:TemplateField>
      
          <asp:TemplateField HeaderText="Approve">
        <ItemTemplate>
             <asp:CheckBox ID="CheckBox1" Enabled=true runat="server" Checked=false />
            
        </ItemTemplate>
           
    </asp:TemplateField>
    
    
    
       
                                                           
                                                          </Columns>
                                                          
                                                          
               <FooterStyle BackColor="White" ForeColor="#000066" />
               
                  <PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" />
                  
                  <HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />
    
    
    
            </asp:GridView>
    Thanks for ur reply can u see the error !!
    Attached Images Attached Images  
    There is no achievement without goals

  6. #6
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: ajax and gridview

    Ah, ok, so it looks like you are using a ModalPopup, from the AJAX Control Toolkit, which I think is the portion that is causing the problem that you are seeing.

    I think this is a case for a complete code sample of what you are using? Is it possible that you can create a small sample application, and upload it here?

    Gary

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2007
    Location
    Karachi
    Posts
    551

    Re: ajax and gridview

    i have an applciation where gridview1 has select button and when click on any row ,gridview2, gridview3 are updated as accrodingly,there is also paging in gridview1 too,so i want if user change teh page both child grid becoem null or blank .

    Code:
     <asp:SqlDataSource ID="SqlDataSource3"  ConnectionString="<%$ ConnectionStrings:reniConnectionString %>"
     runat="server"   SelectCommand="select * from user_company where userid=@userid"  runat="server"></asp:SqlDataSource>
          
        
    											<table width="100%" border="0" cellspacing="0" cellpadding="0">
    											  <tr>
    											  <td align=left width="100%">
    											  <asp:UpdatePanel ID="UpdatePanel1" runat="server">    <contenttemplate>
                                                      <asp:GridView  AllowPaging=True   ID="GridView1" runat="server" 
                                                          DataSourceID=SqlDataSource1  DataKeyNames=userid  
                                                          AutoGenerateColumns="False" BackColor="White" 
                                                          BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" CellPadding="3" 
                                                          Width="449px" style="margin-right: 0px" >
                                                      <RowStyle ForeColor="#000066" />
                                                          <Columns>
                                                              <asp:BoundField DataField="userid" HeaderText="ID" ReadOnly="True" 
                                                                  SortExpression="userid" />
                                                              <asp:BoundField DataField="Name" HeaderText="Name" ReadOnly="True" 
                                                                  SortExpression="Name" />
                                                                   <asp:BoundField DataField="Email" HeaderText="email" ReadOnly="True" 
                                                                  SortExpression="email" />
                                                                    <asp:BoundField DataField="Position" HeaderText="Position" ReadOnly="True" 
                                                                  SortExpression="Position" />
                                                              <asp:CommandField   HeaderText="Select User" ShowHeader="True" 
                                                                  ShowSelectButton="True"  />
                                                                  
                                                                  <asp:TemplateField HeaderText="GFLN MemberShip">
        <ItemTemplate>
            <asp:CheckBox ID="chkgfln" Enabled=false runat="server" Checked='<%# Bind("GFLN_Membership") %>' />
           
        </ItemTemplate>
           
    </asp:TemplateField>
        <asp:TemplateField HeaderText="Company details">
        <ItemTemplate>
        <asp:Button ID="btnViewDetails" runat="server" Text="Details" OnClick="BtnViewDetails_Click" OnClientClick=true />
       <asp:ModalPopupExtender ID="mdlPopup" runat="server" TargetControlID="btnViewDetails" PopupControlID="pnlPopup" 
                    CancelControlID="btnClose" BackgroundCssClass="modalBackground" />
       
        </ItemTemplate>
       
          
    
        
       </asp:TemplateField>
         <asp:TemplateField HeaderText="Want Visa">
        <ItemTemplate>
            <asp:CheckBox ID="chkvisa" Enabled=false runat="server" Checked='<%# Bind("want_visa") %>' />
           
        </ItemTemplate>
           
    </asp:TemplateField>
      
          <asp:TemplateField HeaderText="Approve">
        <ItemTemplate>
             <asp:CheckBox ID="CheckBox1" Enabled=true runat="server" Checked='<%# Bind("Approve") %>' />
            
        </ItemTemplate>
           
    </asp:TemplateField>
    
    
    
       
                                                           
                                                          </Columns>
                                                          
                                                          
               <FooterStyle BackColor="White" ForeColor="#000066" />
               
                  <PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" />
                  
                  <HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />
    
    
    
            </asp:GridView>
            </contenttemplate></asp:UpdatePanel>
            
         
            								          <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                                                          ConnectionString="<%$ ConnectionStrings:reniConnectionString %>" 
                                                           SelectCommand="SELECT * FROM [Users]" ></asp:SqlDataSource>      
                 								  </td>
    												 </tr>
    												 <tr>
    												 <td align=center>
                                                         <asp:Button ID="Button1" runat="server" Text="Approve" /></td>
    												 </tr>
    	</table>
    	 
    	</div>
    	
    	
    	
    	
    	<div visible=true runat=server id=details class="right_txt_space_accm">
      <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode=conditional>
    
    <ContentTemplate>
      <asp:PlaceHolder ID="PlaceHolder1" Visible =false  runat="server">
    	
    	<table width="100%" border="0" cellspacing="0" cellpadding="0">
    	<tr>
    	<td><strong>Companies </strong></td>
    	</tr>
    											  <tr>
    											  <td align=left width="100%">
                                                      <asp:GridView ID="GridView2" runat="server" Width="286px">
                                                      
                                                      </asp:GridView>
                                                  </td> </tr> 
                                                  
                                                           <tr>
    	<td><strong>Attendenes </strong></td>
    	</tr>
    	<tr>  <td align=left width="100%">
                                                      <asp:GridView ID="GridView3" runat="server" Width="286px">
                                                      
                                                      </asp:GridView>
                                                  </td> </tr>
                                                  
                                         
    			</table> 
    			  </asp:PlaceHolder>
                                                   </ContentTemplate> 
                                               
                                                 
                                                 
                                                      <Triggers>
                                               <asp:AsyncPostBackTrigger ControlID="GridView1" EventName="SelectedIndexChanged" />
                                               </Triggers>
                                                  </asp:UpdatePanel> 
                                                
    											  
    	</div>
    There is no achievement without goals

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width