2012-04-27 2 views
0

, когда я войти на страницу, я могу получить все данные без каких-либо проблем My SQL работает правильно, но когда я перейти на страницу он дает ошибку (первый раскрывающийся список значение 0):Когда я открываю веб-страницу, которая включает обратные вызовы, не поддерживается, как я могу ее решить?

«Callbacks не поддерживаются TemplateField потому что некоторые элементы управления не могут правильно обновиться в обратном вызове. Отключите обратные вызовы на «GridView1».

Page Load c#3: 

if (!IsPostBack) 
{ 
    DBConnection db=new DBConnection(); 
    ArrayList listdrp = new ArrayList(); 
    ArrayList listurl = new ArrayList(); 
    listdrp.Insert(0, "SharedItems"); 

    listdrp.Insert(1, "SyndicationItems"); 
    listdrp.Insert(2, "All Items"); 

    DropDownList1.DataSource = listdrp; 

    DropDownList1.DataBind(); 

    GridView1.DataSource = db.getGroupRSS(groupName, DropDownList1.SelectedIndex); 
    GridView1.DataBind(); 

} 

//sql side 
public DataSet getGroupRSS(string name, int drpIndex) 
{ 
    string sql=""; 

    if (drpIndex == 0) 
    { 
     //SQL string to count the amount of rows within the OSDE_Users table 
     sql = "SELECT [RSS_Title], [RSS_ID], R.Syndication, R.Category FROM RSS AS R INNER JOIN Group_URL AS F ON F.URL= R.URL Where F.Group_Name='"+name+"' ORDER BY RSS_Date desc"; 
     // string sql = "SELECT [RSS_Title], [RSS_ID], R.Syndication, R.Category FROM RSS AS R INNER JOIN CombinedFeeds AS C ON C.URL = R.URL WHERE C.Name='" + name + " ' ORDER BY RSS_Date desc"; 
    } 
    else if (drpIndex == 1) 
    { 
     sql = "SELECT [RSS_Title], R.RSS_ID, R.Syndication, R.Category FROM RSS AS R INNER JOIN Group_Shared_Items AS F ON F.RSS_ID= R.RSS_ID Where F.Group_Name='" + name + "' ORDER BY RSS_Date desc"; 
    } 
     SqlDataAdapter adapt = new SqlDataAdapter(sql, Connect()); 
     DataSet ds = new DataSet(); 
     adapt.Fill(ds); 

    // result of query filled into datasource 
    adapt.Dispose(); 

    closeConnection(); 

    return ds; 
} 

стороне клиента

}

  <li> <asp:LinkButton ID="LinkButton1" runat="server" onclick="LinkButton1_Click">Logout</asp:LinkButton> </li> 
     </ul> 
     <table> 

     <tr> 

     <td> 
      <asp:DropDownList ID="DropDownList1" runat="server" 
       onselectedindexchanged="DropDownList1_SelectedIndexChanged" 
       AutoPostBack="True" Height="16px" Width="88px"> 
      </asp:DropDownList> 

     </td> 
     </tr> 
     </table> 


    </div> 
    <div id="center-column"> 
     <div class="top-bar"> 
      <h1 align="center">My Groups&#39; Items</h1> 

      </div><br /> 
      <br /> 
<div> 

    <br /> 
    <br /> 
    <table width="100%"> 
    <tr> 
    <td align='center'> 

    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" 
      onselectedindexchanged="GridView1_SelectedIndexChanged" PageSize="8" 
      AutoGenerateColumns="False" onrowcommand="GridView1_RowCommand" 
      onrowcreated="GridView1_RowCreated" EnableSortingAndPagingCallbacks="True" 
      CellPadding="4" ForeColor="#333333" GridLines="None" 
      onpageindexchanging="GridView1_PageIndexChanging"> 

      <AlternatingRowStyle BackColor="White" /> 

      <Columns> 
      <asp:ButtonField CommandName="AddComment" ButtonType="Image" HeaderText="Comment" 
         ImageUrl="~/images/commentt.png" Text="Comment" 
         ItemStyle-HorizontalAlign="Center" > 

  <asp:ButtonField CommandName="Share" ButtonType="Image" HeaderText="Share with Friends" 
         ImageUrl="~/images/openshare.png" ItemStyle-HorizontalAlign="Center" 
         Text="Share" > 
        <ItemStyle HorizontalAlign="Center"></ItemStyle> 
        </asp:ButtonField> 


        <asp:ButtonField CommandName="ShareGroups" ButtonType="Image" HeaderText="Share with Groups" 
         ImageUrl="~/images/Group.png" ItemStyle-HorizontalAlign="Center" 
         Text="Share" > 
        <ItemStyle HorizontalAlign="Center"></ItemStyle> 
        </asp:ButtonField> 

        <asp:ButtonField ButtonType="Image" HeaderText="Favorites" 
        ImageUrl="~/images/StarEmpty.png" CommandName="Favorite" 
        Text="Add to Favorites" ItemStyle-HorizontalAlign="Center"> 
       <FooterStyle Height="20px" /> 
       <HeaderStyle Width="3px" /> 
       <ItemStyle HorizontalAlign="Center"></ItemStyle> 
       </asp:ButtonField> 

        <asp:ButtonField ButtonType="Image" CommandName="Mail" HeaderText="Send Mail" 
         ImageUrl="~/images/email-icon.png.jpg" Text="Send Mail" 
         ItemStyle-HorizontalAlign="Center" InsertVisible="False" > 

          <ItemStyle HorizontalAlign="Center"></ItemStyle> 

        </asp:ButtonField> 


         <asp:TemplateField HeaderText="RSS Title"> 
      <ItemTemplate> 
       <asp:LinkButton ID="LinkButton2" runat="server" CommandName="View" Font-Size="Small" Font-Underline="False"><%#Eval("RSS_Title") %></asp:LinkButton> 
      </ItemTemplate> 
          <ItemStyle HorizontalAlign="Center" /> 
      </asp:TemplateField> 

       <asp:BoundField DataField="Syndication" HeaderText="Syndication" 
       SortExpression="Syndication" /> 


       <asp:BoundField DataField="Category" HeaderText="Category" 
       SortExpression="Category" /> 


      </Columns> 




      <FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" /> 
      <HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" /> 
      <PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" /> 
      <RowStyle BackColor="#FFFBD6" ForeColor="#333333" /> 
      <SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" /> 
      <SortedAscendingCellStyle BackColor="#FDF5AC" /> 
      <SortedAscendingHeaderStyle BackColor="#4D0000" /> 
      <SortedDescendingCellStyle BackColor="#FCF6C0" /> 
      <SortedDescendingHeaderStyle BackColor="#820000" /> 




    </asp:GridView> 


    </td> 
    </tr> 
    </table> 


    <br /> 

ответ

4

вам нужно подкачки ли? если не установлено EnableSortingAndPagingCallbacks = false. Возможно, вам придется опубликовать свою разметку html, если это не поможет.

+0

Да мне нужно подкачки и я установил позволяет пейджинговой как истинный и я создал индекс страницы, но я понятия не имею о EnableSortingAndPagingCallbacks – leventkalay92

+0

Я отправил свой html-коды, редактируя вопрос – leventkalay92

+0

Ну, я просто поместил GridView из UpdatePanel и установил 'EnableSortingAndPagingCallbacks' как false. Это сработало. Я положил его обратно в UpdatePanel и вернул 'EnableSortingAndPagingCallbacks' как true, он снова работал. Мой код не работал, я не знаю, почему, мой код работает сейчас, я не знаю, почему. Но мне все равно, почему. лол – ErTR

Смежные вопросы