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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.