If e.Row.RowState = DataControlRowState.Edit Then e.Row.Cells(0).Controls(1).Visible = False End If
Protected Sub Projects_RowCreated(ByVal sender As Object, ByVal e As GridViewRowEventArgs) Handles Projects.RowCreated 'display only the first,third, fifth.. I need to display all rows first,second,third... If e.Row.RowState = DataControlRowState.Edit Then e.Row.Cells(0).Controls(1).Visible = False End If 'This one is working If e.Row.RowType = DataControlRowType.DataRow Then For Each cell As TableCell In e.Row.Cells e.Row.Cells(2).Enabled = False e.Row.Cells(4).Enabled = False e.Row.Cells(5).Enabled = False e.Row.Cells(6).Enabled = False e.Row.Cells(7).Enabled = False Next End If End Sub
<asp:GridView ID="Projects" runat="server" AutoGenerateColumns="False" DataKeyNames="ProjectID" width="75%"> <columns> <asp:TemplateField HeaderText="ProjectID" Visible="false"> <itemtemplate> <asp:Label ID="lblProjectID" runat="server" Text='<%# Bind("ProjectID") %>'></asp:Label> </itemtemplate> </asp:TemplateField> <asp:BoundField DataField="Name" HeaderText="Project Number" ReadOnly="true" /> <asp:BoundField DataField="Address" DataFormatString="{0:C}" HeaderText=" Funding" /> <asp:BoundField DataField="Local" DataFormatString="{0:C}" HeaderText="Local" /> <asp:BoundField DataField="Voluntary_Contribution" DataFormatString="{0:C}" HeaderText="Voluntary Contribution" /> <asp:BoundField DataField="Total" DataFormatString="{0:C}" HeaderText="Total" ReadOnly="True" /> <asp:CommandField ShowEditButton="True" /> </columns> <HeaderStyle CssClass="GridHeader" /> </asp:GridView>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)