开发者

Can we avoid postback in gridView...when user click a button in same?

开发者 https://www.devze.com 2023-02-17 10:00 出处:网络
I have a gridview ...in my dotnet 2.0 - web application. gridview has 2 columns...first column is ID..and second is a \"link button\"..as shown below.

I have a gridview ...in my dotnet 2.0 - web application.

gridview has 2 columns...first column is ID..and second is a "link button"..as shown below.

On click of this link, I have to display a popup..and I'm using ajax ModalPopupExtender.

I am able to see the popup.

But the issue is...when I click on this link button the postback happens...and the gridview.datasource is NULL. So I have to fetch the data from database and bind the gridview again.

Please help me to find a way to avoid this.

<asp:GridView ID="AvailableGridView" >
<Columns>
<asp:BoundField ItemStyle-CssClass="ItemStyleCss" ItemStyle-HorizontalAlign="Center"
HeaderStyle-CssClass="GridHeaderRow" HeaderText="ID" DataField="ClaimCodeGroupIdText"
/>
     <asp:TemplateField HeaderText="View" ShowHeader="False">                                                                                <ItemTemplate>
               <asp:LinkButton  CssClass="localNavigation" ID="ViewCCGLinkButton"         
       Text="View" CommandName="View"                                                                          CommandArgument='<%#开发者_如何学运维 Eval("ClaimCodeGroupId") %>' runat="server"></asp:LinkButton>
            </ItemTemplate>
       <ItemStyle HorizontalAlign="Center" />
     <HeaderStyle CssClass="GridHeaderRow" />
    </asp:TemplateField>

</Columns>
<asp:GridView />


You can set ajax toolkit modal popup to load client side and not cause a postback.

But if you have to get data from the server side, i think you have following options

  1. Use ajax to load server data
  2. Save the selected Id in the hidden text box and on postback read Id thru hidden textbox
  3. Use jQuery BlockUI and ajax to load server data (personal fav.)

Pick your options according to ur need and requirement.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号