在网格视图中我没有从控件获得更新的值(Ex.TextBox) [英] In Grid View I haven't got the Updated Value from controls(Ex.TextBox)

查看:65
本文介绍了在网格视图中我没有从控件获得更新的值(Ex.TextBox)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在下面显示的G​​ridView中,当我添加或更新行时,我没有从控件(Ex.TextBox)获得更新值。

In the below shown GridView I haven't got the Updated Value from controls(Ex.TextBox) when I am Adding or Updating Rows.

<asp:GridView ID="grdView" runat="server" ShowFooter="True" Font-Names="Arial"

                     Font-Size="10pt" CellPadding="4" AutoGenerateColumns="false"

                                  CssClass="CSSTableGenerator" Width="100%"

                     OnRowCommand="grdView_rowcommand" OnRowUpdating="grdView_Updating"

                     OnRowEditing="grdView_rowediting"  OnRowCancelingEdit="grdView_RowCanceling"

                     OnRowDeleting="grdView_rowdeleting" >
                   <Columns>

                       <asp:TemplateField HeaderText="Sr.No.">
                       <HeaderTemplate>
                       <asp:Label runat="server" ID="lblSN1" Text="S.N."></asp:Label>
                        </HeaderTemplate>
                           <ItemTemplate>
                           <asp:Label runat="server" ID="lblS" Text='<%#Container.DataItemIndex+1 %>'></asp:Label>
                               <asp:Label runat="server" ID="lblSN" Text='<%#Eval("PID") %>' Visible="false" ></asp:Label>
                           </ItemTemplate>
                           <EditItemTemplate>
                             <asp:Label runat="server" ID="lblSAdd" Text='<%#Eval("PID") %>' Visible="false"></asp:Label>
                           </EditItemTemplate>
                           <FooterTemplate>
                           <asp:Label runat="server" ID="lblAdd"></asp:Label>
                           </FooterTemplate>
                       </asp:TemplateField>


                       <asp:TemplateField HeaderText="Pattern Name">
                           <ItemTemplate>
                               <asp:Label ID="lblPattern" runat="server" Text='<%#Eval("Year") %>'></asp:Label>
                           </ItemTemplate>
                           <EditItemTemplate>
                           <asp:TextBox runat="server" ID="txtPName" Text='<%#Eval("Year") %>'></asp:TextBox>
                           </EditItemTemplate>
                            <FooterTemplate>
                           <asp:TextBox runat="server" ID="txtPattermY" ValidationGroup="val1"></asp:TextBox>
                           <asp:RequiredFieldValidator runat="server"  ControlToValidate="txtPattermY" ValidationGroup="val1" ID="rfvtxtBuildingN" ErrorMessage="*" ForeColor="Red"></asp:RequiredFieldValidator>
                           </FooterTemplate>
                       </asp:TemplateField>

                       <asp:TemplateField HeaderText="Edit/Delete">
                       <ItemTemplate>
                       <asp:LinkButton runat="server" ID="lbtnEdit" CommandName="Edit" Text="Edit"></asp:LinkButton>
                       <asp:LinkButton runat="server" ID="lbnDelete" Text="Delete" CommandName="Delete"></asp:LinkButton>
                       </ItemTemplate>
                       <EditItemTemplate>
                       <asp:LinkButton runat="server" ID="lbtnUpdate" CommandName="Update" Text="Update"></asp:LinkButton>
                       <asp:LinkButton runat="server" ID="lblCancel" Text="Cencel" CommandName="Cancel"></asp:LinkButton>
                       </EditItemTemplate>
                       <FooterTemplate>
                       <asp:LinkButton runat="server" ID="btnAdd" Text="Add" CommandName="Add" ValidationGroup="val1" CssClass="btn-success" Height="30px" Width="80px"></asp:LinkButton>
                       </FooterTemplate>

                      </asp:TemplateField>


                   </Columns>
                     <FooterStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                     <RowStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                 </asp:GridView>







请帮帮我




Please Help me out

推荐答案

希望你的pageload中的bind方法遇到问题请看下面的解决方案

Hope so your bind method in pageload is getting problem see the below solution
protected void Page_Load(object sender, EventArgs e)
{
    bind();
    if (!Page.IsPostBack)
    {
        bind();
    }
}



错了。



应该是:


is wrong.

It should be:

protected void Page_Load(object sender, EventArgs e)
{
    if (!Page.IsPostBack)
    {
        bind();
    }
}


这篇关于在网格视图中我没有从控件获得更新的值(Ex.TextBox)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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