为什么我的boundfield不能在gridview内使用updatepanel?

时间:2013-02-21 14:37:23

标签: asp.net gridview updatepanel

我在更新面板内有一个网格视图,其中有多个绑定字段,最后两个绑定字段,如图所示,单击时显示另一个网格视图,没有回发但下载不起作用,除了我设置了脚本管理器的EnablePartialRendering =“false” 但在这种情况下,updatepanel无法显示绑定字段

enter image description here

    <asp:ScriptManager ID="ScriptManager1"  runat="server">  
 </asp:ScriptManager>  
 <asp:UpdatePanel ID="UpdatePanel1" runat="server" >  
<contenttemplate>  

 <div id="DivImages" runat="server" visible="false" class="block rnd">
            <div class="title2">الأحكـــــــــــام</div>
            <div class="content2">

     <asp:gridview ID="GvImages" runat="server"  PagerStyle-CssClass="pages"   AllowPaging="True" 
                        AutoGenerateColumns="False" CellSpacing="-1" Width="100%" DataKeyNames="DocCode,IssuesID" 
       CssClass="dataGrid"   OnPageIndexChanging="GvImages_PageIndexChanging" GridLines="None" 
                        PageSize="20" OnRowCommand="GvImages_RowCommand" 
                        OnSelectedIndexChanging="GvImages_SelectedIndexChanging">
<AlternatingRowStyle BackColor="White" />
<Columns>

<asp:TemplateField HeaderText="رقم السجــل">   
     <ItemTemplate>
             <%# Container.DataItemIndex + 1 %>   
     </ItemTemplate>
 </asp:TemplateField>


 <asp:BoundField DataField="DocCode" HeaderText="رقم الحكم/ القرار"   SortExpression="DocCode" />
    <asp:BoundField DataField="IssuesNum" HeaderText="كود القضيه" 
        SortExpression="IssuesNum" />
                <asp:BoundField DataField="TypeName" HeaderText="نوع القضيه" 
        SortExpression="TypeName" />
         <asp:BoundField DataField="Year" HeaderText="السنه" 
        SortExpression="Year" />

            <asp:BoundField DataField="Area" HeaderText="المنطقه" 
        SortExpression="Area" />



      <asp:BoundField DataField="DocTypeName" HeaderText="تصنيــف المستند" SortExpression="DocTypeName" />

    <asp:BoundField DataField="Name" HeaderText="نوع المستند" 
        SortExpression="Name" />

            <asp:TemplateField  HeaderText="حذف">

                            <ItemTemplate>
                                <asp:LinkButton ID="cmd_DeleteRow"   CommandName="DeleteRow"  CssClass="delete" ToolTip="حذف" CommandArgument="<%# ((GridViewRow)Container).RowIndex %>" runat="server" OnClientClick="return confirmDeleteRow()" />
                            </ItemTemplate>
                            <HeaderStyle Width="125px" />
                        </asp:TemplateField>

      <asp:CommandField SelectText="عرض"  HeaderText="عرض" ShowHeader="True" ShowSelectButton="True">  
                    <HeaderStyle HorizontalAlign="Right" />
                    </asp:CommandField>

                        <asp:TemplateField  HeaderText="تحميل">

                            <ItemTemplate>
                                <asp:LinkButton ID="DownLoad" CommandName="DownLoad"   Text="تحميل" ToolTip="تحميل" CommandArgument="<%# ((GridViewRow)Container).RowIndex %>" runat="server" />
                            </ItemTemplate>
                            <HeaderStyle Width="125px" />
                        </asp:TemplateField>


</Columns>
  <RowStyle Height="25px" />
                    <HeaderStyle Height="30px" />
                    <PagerStyle CssClass="pages" Wrap="false" />
</asp:gridview>

</div>
</div>


 </contenttemplate>
 <Triggers>

    

按钮搜索中的

我绑定了我的网格

就像在这段代码中一样

    protected void ShowDoc(string sCondition)
    {
    //declare connection by pass connection string from web.config
    SqlConnection sqlcon = new SqlConnection
        (ConfigurationManager.ConnectionStrings["SystemConn"].ConnectionString);

    //declare sql statment  as astring variable

    if (Session["Image"] != null)
    {
        Session.Remove("Image");
    }
    try
    {
        SqlStatment = string.Format("select distinct IssuesNum,DocType,DocTypeSub,DocCode,DocTypeName,Name,IssuesID,TypeID,TypeName,Area,IssuesNumSplited,Year   from [View_ImagesSearch] Where {0}  Order By [IssuesNumSplited] ASC", sCondition);

        //create asql command and pass for it the connection string and sql statment
        SqlCommand sqlcom = new SqlCommand(SqlStatment, sqlcon);

        //create data adaptor to bring data from database
        SqlDataAdapter sad = new SqlDataAdapter(sqlcom);

        // declare dataset to store data from data base in it
        DataSet ds = new DataSet();

        //fill data set with data adabter that contain data from database
        sad.Fill(ds);
        lblDocCount2.Text = ds.Tables[0].Rows.Count.ToString();
        Session["Image"] = ds;
        GvImages.DataSource = ds;
        GvImages.DataBind();

    }
    catch (Exception ex)
    {
        par_ErrorMessage.Visible = true;
        par_ErrorMessage.InnerText = ex.Message;
    }
   }

当我点击名为عرضupdatepanel的命令工作时,显示另一个gridview 但是当iclick项目模板下载不工作时,直到我设置EnablePartialRendering =“False”

1 个答案:

答案 0 :(得分:0)

UpdatePanel上调用 DataBind 后,确保您在GridView上调用更新

GridView.DataBind();
UpdatePanel.Update();

有关其他可能的解决方案,请参阅this