如何在克服网格视图外侧的保存按钮后逐行reed网格视图的所有值 [英] how to reed all the values of a grid view row by row after cliking a save button which is out side the gridview

查看:61
本文介绍了如何在克服网格视图外侧的保存按钮后逐行reed网格视图的所有值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个gridview1,因为我占用了四个字段



i am having a gridview1 in that i am taking four fields

<asp:GridView ID="gridviewFeeDetailsForAnnualy" runat="server" AutoGenerateColumns="False"

                                        BackColor="White" BorderColor="White" BorderStyle="Ridge" BorderWidth="2px"

                                        CellPadding="3" CellSpacing="1" GridLines="None" Width="783px">
                                        <RowStyle BackColor="#DEDFDE" ForeColor="Black" HorizontalAlign="Center" />
                                        <Columns>
                                            <asp:TemplateField HeaderText="Student ID" Visible="false">
                                                <ItemTemplate>
                                                    <asp:Label ID="lblStudent_ID" runat="server" Text='<%#Eval("Student_ID")%>'></asp:Label>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderText="Fee Type">
                                                <ItemTemplate>
                                                    <asp:Label ID="lblFee_Type" runat="server" Text='<%#Eval("Fee_Type")%>'></asp:Label>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderText="Fee Amount">
                                                <ItemTemplate>
                                                    <asp:Label ID="lblFee_Amount" runat="server" Text='<%#Eval("amount")%>'></asp:Label>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderText="Paid_Amount">
                                                <ItemTemplate>
                                                    <asp:Label ID="lblPaid_Amount" runat="server" Text='<%#Eval("Paid_Amount")%>'></asp:Label>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderText="Amount To Pay">
                                                <ItemTemplate>
                                                    <asp:Label ID="lblAmount_To_Pay" runat="server" Text='<%#Eval("total_amount")%>'></asp:Label>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderText="Amount">
                                                <ItemTemplate>
                                                    <asp:TextBox ID="txtAmount" runat="server" Width="60px"></asp:TextBox>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:ButtonField CommandName="ViewDetails" HeaderText="Payment Details" Text="View Details" />
                                            <%--<asp:CommandField ShowEditButton="true" HeaderText="Edit" ShowCancelButton="false"/>--%>
                                        </Columns>
                                        <FooterStyle BackColor="#C6C3C6" ForeColor="Black" />
                                        <PagerStyle BackColor="#C6C3C6" ForeColor="Black" HorizontalAlign="Right" />
                                        <SelectedRowStyle BackColor="#9471DE" Font-Bold="True" ForeColor="White" />
                                        <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#E7E7FF" />
                                    </asp:GridView>







输入每行文本框中的值后我会点击保存按钮然后我想读取gridview1上的所有值然后我可以将记录逐个插入数据库。这是我的problem.like下面我正在尝试,但价值没有得到



protected void btnPayFee_Click(object sender,EventArgs e)

{

for(int i = 0;我< gridviewCandidateDetails.Rows.Count;我++)

{

标签Fee_type =(标签)gridviewCandidateDetails.Rows [I] .FindControl( lblFee_Type);

文本框txtamount = (文本框)gridviewCandidateDetails.Rows [I] .FindControl( txtAmount);

}

}




after entering the values in text box of each row i will click save button then i want to read all the values on the gridview1 then i can insert the records into database one by one.that was my problem.like below i am trying but value is not getting

protected void btnPayFee_Click(object sender, EventArgs e)
{
for (int i = 0; i < gridviewCandidateDetails.Rows.Count; i++)
{
Label Fee_type = (Label)gridviewCandidateDetails.Rows[i].FindControl("lblFee_Type");
TextBox txtamount = (TextBox)gridviewCandidateDetails.Rows[i].FindControl("txtAmount");
}
}

推荐答案

我认为你在IsPostBack之外的Page_Load事件中绑定GridView会让你绑定IsPostBack中的代码检查它是否可行。
i think you are binding GridView at Page_Load event outside of IsPostBack put you binding code in IsPostBack check it''ll work.


参考此示例 -

http://www.bipinjoshi.net/articles/4fbf57bb-e777-453e-8b78-2009a922c5ec.aspx [ ^ ]





http://www.aspforums.net/Threads/138704/edit-update-multiple-gridview-row-and-cell-values-on-a-single-click/ [ ^ ]
Refer this Example-
http://www.bipinjoshi.net/articles/4fbf57bb-e777-453e-8b78-2009a922c5ec.aspx[^]


http://www.aspforums.net/Threads/138704/edit-update-multiple-gridview-row-and-cell-values-on-a-single-click/[^]


protected void btnPayFee_Click(object sender,EventArgs e){for(int i = 0;我< gridviewCandidateDetails.Rows.Count; i ++){Label Fee_type =(Label)gridviewCandidateDetails.Rows [i] .FindControl(lblFee_Type); TextBox txtamount =(TextBox)gridviewCandidateDetails.Rows [i] .FindControl(txtAmount); }}
protected void btnPayFee_Click(object sender, EventArgs e) { for (int i = 0; i < gridviewCandidateDetails.Rows.Count; i++) { Label Fee_type = (Label)gridviewCandidateDetails.Rows[i].FindControl("lblFee_Type"); TextBox txtamount = (TextBox)gridviewCandidateDetails.Rows[i].FindControl("txtAmount"); } }


这篇关于如何在克服网格视图外侧的保存按钮后逐行reed网格视图的所有值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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