Select Button

Hello,

I am attempting to implement a select button to drill from a list of records (in a gridview) to a specific records information on another page.  I am getting the following error:

Callbacks are not supported on CommandField when the select button is enabled because other controls on your page that are dependent on the selected value of 'GridView1' for their rendering will not update in a callback.  Turn callbacks off on 'GridView1'.

I have read descriptions on the internet and I cannot seem to find a satisfactory solution.  I have turned sorting off along with turning EnableSortingandPaging callbacks to false.  I am still getting the error.

My gridview code is as follows:

 <asp:GridView ID="SchoolList" runat="server" AllowPaging="True"
                 AutoGenerateColumns="False" BackColor="White"
                 BorderColor="#000066" BorderStyle="Solid" CaptionAlign="Left"
                 DataSourceID="school_list_source" ForeColor="#000066" GridLines="Horizontal"
                 PageSize="25" Width="864px" onselectedindexchanged="SchoolSelect"
                 EnableTheming="True">
                 <Columns>
                     <asp:CommandField ShowSelectButton="True" />
                     <asp:BoundField DataField="ROW_ID" HeaderText="School ID"
                         SortExpression="ROW_ID" />
                     <asp:BoundField DataField="NAME" HeaderText="Name" SortExpression="NAME" />
                     <asp:BoundField DataField="ADDRESS_1" HeaderText="Address " 
                         SortExpression="ADDRESS_1" />
                     <asp:BoundField DataField="CITY" HeaderText="City" SortExpression="CITY" />
                     <asp:BoundField DataField="STATE" HeaderText="State" SortExpression="STATE" />
                     <asp:BoundField DataField="PHONE_NUMBER_1" HeaderText="Phone #"
                         SortExpression="PHONE_NUMBER_1" />
                     <asp:BoundField DataField="EXT_1" HeaderText="Ext." SortExpression="EXT_1" />
                     <asp:BoundField DataField="NAME1" HeaderText="Company" SortExpression="NAME1" />
                 </Columns>
                 <PagerTemplate>
                     &nbsp;
                 </PagerTemplate>
                 <HeaderStyle BackColor="#000066" ForeColor="#FFFF66" HorizontalAlign="Center"
                     VerticalAlign="Middle" />
                 <EditRowStyle BackColor="#FFFFCC" BorderColor="#000066" BorderStyle="Solid"
                     ForeColor="#000066" />
                 <AlternatingRowStyle BackColor="#FFFF66" BorderColor="#000066"
                     BorderStyle="None" ForeColor="#000066" />
             </asp:GridView>

My function that I am trying to call is as follows:

  public void SchoolSelect(Object sender, EventArgs e)
  {
     //Gathers the school id from the selected school, sets a session variable and redirects to the form page
      GridViewRow row = SchoolList.SelectedRow;
      if (row == null)
      {
      //Not exactly sure why i need this but it works with this in there
      }
      else
      {
          Session["LastSchoolID"] = row.Cells[1].Text;
          Response.Redirect("school_form_1.aspx");
      }
  }

I am also unsure why it is the Response.Redirect that blows things up here.

any information would be extremely appreciated.

Thanks!
uconnfb13Asked:
Who is Participating?
 
Ajay SharmaCommented:
I think you should use OnSelectedIndexChanged event,

See:
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.selectedindexchanged.aspx

Alternatively you can put a TemplateColumn and place button in there, handle the buttonlclick event in OnRowCommand event and redirect user.
0
 
uconnfb13Author Commented:
Thanks for the reply.  Looking at my code, I have attempted to use OnSelectedIndexChanged, which calls the SchoolSelect function.  The problem is when the school select function fires, the following error comes up:

"allbacks are not supported on CommandField when the select button is enabled because other controls on your page that are dependent on the selected value of 'GridView1' for their rendering will not update in a callback.  Turn callbacks off on 'GridView1'."


have read descriptions on the internet and I cannot seem to find a satisfactory solution.  I have turned sorting off along with turning EnableSortingandPaging callbacks to false.  I am still getting the error.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.