Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.6k views
in Technique[技术] by (71.8m points)

asp.net - GridView's NewValues and OldValues empty in the OnRowUpdating event

I have the GridView below. I am binding to a custom datasource in the code behind. It gets into the "OnRowUpdating" event just fine, but there are no NewValues or OldValues. Any suggestions as to how I can get these values?

<asp:GridView   ID="gv_Personnel" 
                        runat="server" 
                        OnRowDataBound="gv_Personnel_DataBind" 
                        OnRowCancelingEdit="gv_Personnel_CancelEdit" 
                        OnRowEditing="gv_Personnel_EditRow" 
                        OnRowUpdating="gv_Personnel_UpdateRow"
                        AutoGenerateColumns="false" 
                        ShowFooter="true" 
                        DataKeyNames="BudgetLineID"
                        AutoGenerateEditButton="true" 
                        AutoGenerateDeleteButton="true"
                        >
            <Columns>                 
                <asp:BoundField HeaderText="Level of Staff" DataField="LineDescription" />
                <%--<asp:BoundField HeaderText="Hrs/Units requested" DataField="NumberOfUnits" />--%>
                <asp:TemplateField HeaderText="Hrs/Units requested">
                    <ItemTemplate>
                        <%# Eval("NumberOfUnits")%>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:TextBox ID="tb_NumUnits" runat="server" Text='<%# Bind("NumberOfUnits")%>' />
                    </EditItemTemplate>
                </asp:TemplateField>
                <asp:BoundField HeaderText="Hrs/Units of Applicant Cost Share" DataField="" NullDisplayText="0" />
                <asp:BoundField HeaderText="Hrs/Units of Partner Cost Share" DataField="" NullDisplayText="0" />
                <asp:BoundField FooterStyle-Font-Bold="true" FooterText="TOTAL PERSONNEL SERVICES:" HeaderText="Rate" DataFormatString="{0:C}" DataField="UnitPrice" />
                <asp:TemplateField HeaderText="Amount Requested" ItemStyle-HorizontalAlign="Right" FooterStyle-HorizontalAlign="Right"  FooterStyle-BorderWidth="2" FooterStyle-Font-Bold="true"/>
                <asp:TemplateField HeaderText="Applicant Cost Share" ItemStyle-HorizontalAlign="Right" FooterStyle-HorizontalAlign="Right" FooterStyle-BorderWidth="2" FooterStyle-Font-Bold="true"/>
                <asp:TemplateField HeaderText="Partner Cost Share" ItemStyle-HorizontalAlign="Right" FooterStyle-HorizontalAlign="Right" FooterStyle-BorderWidth="2" FooterStyle-Font-Bold="true"/>
                <asp:TemplateField HeaderText="Total Projet Cost" ItemStyle-HorizontalAlign="Right" FooterStyle-HorizontalAlign="Right" FooterStyle-BorderWidth="2" FooterStyle-Font-Bold="true"/>
            </Columns>
        </asp:GridView>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Im not sure if this would help..but this is what i found in msdn site

The Keys, OldValues and NewValues collections are automatically populated only when the GridView control is bound to data by using the DataSourceID property.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...