单击“编辑图像"按钮时,Gridview刷新asp.net页 [英] Gridview Refresh asp.net page when edit image button click

查看:70
本文介绍了单击“编辑图像"按钮时,Gridview刷新asp.net页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Gridview.单击Gridview图像按钮时,外部Gridview控件被填充,这意味着其他控件位于一个面板内.问题是,当单击Gridview控件时,将其填充在面板内部.但页面刷新.
谁能帮我避免闪烁(刷新)asp.net页面.
下面的代码描述.预先感谢.请尝试给我简单易懂的代码,因为我是系统中的新手.

I have one Gridview.when click on Gridview image button, outside Gridview controls are fillup,which means other controls are inside one panel. problem is that, when click on Gridview controls are fill up inside panel. but page refresh.
Can anyone please help me to avoid flickering(Refresh) the asp.net page.
Code below describe.Thanks in advance.Please try to give me easy and understanding code as i am very new in the system.

<asp:GridView ID="displaygrid" runat="server" Width="100%" DataKeyNames="ncode" AllowCustomPaging="True" AllowPaging="True" AutoGenerateColumns="False"

AllowSorting="True" onrowediting="displaygrid_RowEditing">
<SelectedRowStyle ForeColor="Blue" CssClass="td" />
<AlternatingRowStyle Height="17px" CssClass="tdbox2" />
  <RowStyle Height="17px" CssClass="tdbox" />
     <HeaderStyle Font-Bold="True" ForeColor="Black" HorizontalAlign="Left" CssClass="tdbox1" />
                                              <Columns>
                                                 <asp:ButtonField Text="&lt;img alt=Edit border=0  src=./images/edit_icon.gif&gt;"  HeaderText="Edit" CommandName="Edit" >
                                                  <HeaderStyle Width="3%" />
                                                  <ItemStyle Font-Bold="True" HorizontalAlign="Center" ForeColor="Black" VerticalAlign="Middle"></ItemStyle>
                                                 </asp:ButtonField>

                                                  <asp:ButtonField Text="&lt;img alt=Delete border=0  src=./images/delete_icon.gif&gt;" HeaderText="Delete" CommandName="Delete">
                                                        <HeaderStyle Width="3%"></HeaderStyle>
                                                        <ItemStyle Font-Bold="True" Wrap="False" HorizontalAlign="Center" ForeColor="Black"></ItemStyle>
                                                    </asp:ButtonField>
                                                    <asp:ButtonField Text="&lt;img alt=View border=0  src=./images/view_icon.gif&gt;" HeaderText="View" CommandName="Cancel">
                                                        <HeaderStyle Width="3%"></HeaderStyle>
                                                        <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle"></ItemStyle>
                                                    </asp:ButtonField>
                                                    <asp:TemplateField HeaderText="User Full Name">
                                                        <ItemTemplate>
                                                            <asp:Label ID="lblUserFullName" runat="server" Text='<%# Bind("UserFullName") %>'></asp:Label>
                                                        </ItemTemplate>

                                                  </asp:TemplateField>
                                                    <asp:TemplateField HeaderText="Config Item">
                                                        <ItemTemplate>
                                                            <asp:Label ID="lblConfigItemVal" runat="server" Text='<%# Bind("ConfigItem") %>'></asp:Label>
                                                        </ItemTemplate>
                                                  </asp:TemplateField>
                                                  <asp:TemplateField HeaderText="Component">
                                                      <ItemTemplate>
                                                          <asp:Label ID="lblComponentVal" runat="server" Text='<%# Bind("Component") %>'></asp:Label>
                                                      </ItemTemplate>

                                                  </asp:TemplateField>
                                              </Columns>
                                              <PagerStyle VerticalAlign="Middle" HorizontalAlign="Right" CssClass="td"></PagerStyle>
                                            </asp:GridView>



<asp:Panel id="PnlEntry" runat="server" Width="100%" >
          <table id="Table2" cellspacing="2" cellpadding="1" width="98%" align="center" border="0">
                                <tr>
                                    <td class="tdbox1" align="left" colspan="5" height="25px"><strong>&nbsp; Daily Work Log</strong></td>
                                </tr>
                                <tr>
                                    <td class="tdbox" align="left" width="15%" >&nbsp; Config Item &nbsp; </td>
                                    <td class="tdbox2" align="left"  width="25%" >
                                        <asp:DropDownList ID="ddlConfigItem" runat="server" Width="70%" CssClass="textarea1" height="23px"></asp:DropDownList>
                                    </td>

                                <td class="tdbox2" align="left"  width="20%" ></td>

                                    <td class="tdbox" align="left" width="15%" >&nbsp; Component &nbsp; </td>
                                    <td class="tdbox2" align="left" width="25%" >
                                       <asp:DropDownList ID="ddlComponent" runat="server" Width="71%" CssClass="textarea1" height="25px"></asp:DropDownList>
                                    </td>
                                </tr>

</table>



.CS page

protected void displaygrid_RowEditing(object sender, GridViewEditEventArgs e)
        {
            int index = Convert.ToInt32(displaygrid.DataKeys[e.NewEditIndex].Value.ToString());
            EditGrid(index);

        }

public void EditGrid(int id)
        {
            string stredit = "SELECT * FROM dbo.vw_DWL WHERE ncode=" + id;
            CommanClass cl = new CommanClass();
            DataSet dsTobind = cl.Getdataset(stredit);

            if (dsTobind.Tables[0].Rows.Count > 0)
            {
                ddlConfigItem.SelectedValue = dsTobind.Tables[0].Rows[0]["ConfigItemId"].ToString();
                ddlComponent.SelectedValue = dsTobind.Tables[0].Rows[0]["ComponentId"].ToString();
                txtSM.Text = dsTobind.Tables[0].Rows[0]["SM9"].ToString();
                txtDesc.Text = dsTobind.Tables[0].Rows[0]["Description"].ToString();
                DatePicker1.SelectedDate = Convert.ToDateTime(dsTobind.Tables[0].Rows[0]["Date"].ToString());
                txtBulkRequest.Text = dsTobind.Tables[0].Rows[0]["BulkRequest"].ToString();
                txtSeperate.Text = dsTobind.Tables[0].Rows[0]["TimeLogged"].ToString();


            }
        }

推荐答案

plz,请参阅此链接
http://stackoverflow.com/questions/718394/prevent-page-refresh-in- c-sharp [ ^ ]
plz,see this link
http://stackoverflow.com/questions/718394/prevent-page-refresh-in-c-sharp[^]


这篇关于单击“编辑图像"按钮时,Gridview刷新asp.net页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆