Gridview列问题 [英] Gridview columns problem

查看:60
本文介绍了Gridview列问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I have one Grid d view in that i have used bound Field to Bind the grid view
also i have fired the 4 Even
1) Row Command
2) Row Editing
3) Row Deleting
4) Page Index Changing Events.

while I click on The Edit button of the Gridview which i have taken in Template Field. In code behind in Row command event it fetch the all details using Command Arguments. and fill the data in webform.

The issue is when while am clicking two time of Edit button in gridview my gridview row converted into the text. while i have not used any textbox control in grid view.

So please help me to solve out this problem







<asp:GridView ID="grFees" runat="server" CssClass="label " AutoGenerateColumns="False"
                                        OnRowCommand="grFees_RowCommand" BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px"
                                        OnRowEditing="grFees_RowEditing" OnRowDeleting="grFees_RowDeleting" CellPadding="3"
                                        ForeColor="Black" GridLines="None" Font-Names="verdana" Font-Size="11px" AllowPaging="true"
                                        OnPageIndexChanging="grFees_PageIndexChanging" 
                                        onrowupdating="grFees_RowUpdating">
                                        <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                                        <RowStyle Height="20px" BackColor="#F7F6F3" ForeColor="#333333" />
                                        <Columns>
                                            <asp:BoundField DataField="ParticularName" HeaderText="Particular Name">
                                                <HeaderStyle BackColor="#9097A9" HorizontalAlign="Left" VerticalAlign="Middle" Width="150px" />
                                                <ItemStyle HorizontalAlign="Left" VerticalAlign="Middle" Wrap="false" />
                                            </asp:BoundField>
                                            <asp:BoundField DataField="FeeType" HeaderText="Fee Type">
                                                <HeaderStyle BackColor="#9097A9" HorizontalAlign="Center" VerticalAlign="Middle"
                                                    Width="85px" />
                                                <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Wrap="false" />
                                            </asp:BoundField>
                                            <asp:BoundField DataField="DiscountAmount" HeaderText="Discount Amount">
                                                <HeaderStyle BackColor="#9097A9" HorizontalAlign="Left" VerticalAlign="Middle" Width="110px"
                                                    Wrap="True" />
                                                <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Wrap="true" Width="100px" />
                                            </asp:BoundField>
                                            <asp:BoundField DataField="PaymentType" HeaderText="Payment Type">
                                                <HeaderStyle BackColor="#9097A9" HorizontalAlign="Left" VerticalAlign="Middle" Width="78px"
                                                    Wrap="True" />
                                                <ItemStyle HorizontalAlign="Left" VerticalAlign="Middle" Wrap="true" Width="100px" />
                                            </asp:BoundField>
                                            <asp:TemplateField HeaderText="Edit">
                                                <ItemTemplate>
                                                    <asp:ImageButton ID="ImageButton3" runat="server" CausesValidation="false" ImageUrl="~/_Images/edit-icon.gif"
                                                        CommandName="Edit" CommandArgument='<%# Eval("ParticularsID")%>' />
                                                </ItemTemplate>
                                                <HeaderStyle HorizontalAlign="Center" BackColor="#9097A9" />
                                                <ItemStyle HorizontalAlign="Center" Width="50px" />
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderText="Delete">
                                                <ItemTemplate>
                                                    <asp:ImageButton ID="ImageButton4" runat="server" CausesValidation="false" ImageUrl="~/_Images/hr.gif"
                                                        CommandName="Delete" CommandArgument='<%# Eval("ParticularsID")%>' OnClientClick="javascript:return confirm('Are you sure, you want to delete Record?');" />
                                                </ItemTemplate>
                                                <HeaderStyle BackColor="#9097A9" HorizontalAlign="Center" />
                                                <ItemStyle HorizontalAlign="Center" Width="50px" />
                                            </asp:TemplateField>
                                        </Columns>
                                        <FooterStyle BackColor="#CCCCCC" Font-Bold="True" Font-Names="Verdana" Font-Size="11px" />
                                        <PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
                                        <SelectedRowStyle BackColor="#79B1F0" Font-Bold="True" ForeColor="White" />
                                        <HeaderStyle BackColor="#267DA1" Font-Bold="True" ForeColor="White" />
                                        <AlternatingRowStyle BackColor="#CCCCCC" />
</asp:GridView>

推荐答案

如果您想在编辑按钮上使用,您的网格将不会显示文本框。

使用

protected void grFees_RowCommand(object sender,GridViewCommandEventArgs e)

{



if(e.CommandName.Equals(编辑))

{

//你的代码。

}

}



从您的网格视图中删除以下



OnRowEditing =grFees_RowEditing。
If you want that on edit button your grid will not show text boxes.
the use
protected void grFees_RowCommand(object sender, GridViewCommandEventArgs e)
{

if (e.CommandName.Equals("Edit"))
{
// your code.
}
}

Remove following

OnRowEditing="grFees_RowEditing" from your grid view.


你需要在edititemtemplate中设计的gridviewe模板字段



将包含可以被感染的数据的控件使用更新或删除命令
the gridviewe templatefield you need to design in the edititemtemplate

the the controls which will contains the data tha can be afected when using update or delete command


这篇关于Gridview列问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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