Click here to Skip to main content
15,921,941 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I Want grid view column hide but these value use.If possible then pls help me.
XML
 <asp:GridView ID="grdManualAttendance"  runat="server" DataKeyNames="AttendanceID" AutoGenerateColumns="False"
                                        BackColor="White" BorderColor="#999999" BorderStyle="None" BorderWidth="1px"
                                          Font-Size="Small" Width="100%" >
                                        <FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
                                        <RowStyle BackColor="#EEEEEE" ForeColor="Black" />
                                        <Columns>
                                        <asp:TemplateField ItemStyle-Width="20px">
                                            <HeaderTemplate>
                                                Delete
                                            </HeaderTemplate>
                                            <ItemTemplate>
                                                <asp:CheckBox ID="chkDelete" runat="server" />
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                            <asp:BoundField DataField="AttendanceID" HeaderText="AttendanceID" visible="false" ItemStyle-Width="20px" />
                                            <asp:BoundField DataField="Date" DataFormatString="{0:dd/mm/yyyy}" HeaderText="Date"
                                                ItemStyle-Width="20px" />
                                            <asp:BoundField DataField="Time" DataFormatString="{0:hh:mm:ss}" HeaderText="Time" ItemStyle-Width="20px" />
                                            <asp:BoundField DataField="GraceTime" HeaderText="GraceTime"
                                                ItemStyle-Width="20px" />
                                                <asp:BoundField DataField="IsActive" HeaderText="IsActive"
                                                ItemStyle-Width="20px" />

                                                <asp:BoundField DataField="Remarks" HeaderText="Remarks"
                                                ItemStyle-Width="20px" />
</Gridview>

AttendanceID colunm Hide but This id need for Delete.But i cant find this ID. Pls give appropriate solution.
Posted
Updated 17-Oct-12 20:07pm
v2

May it will help you
Make then field as a TemplateField and bind the ID in a HiddenField and while deleting find the Control HiddenField on that particular column.

Thanks
 
Share this answer
 
use DataKeyNames property of gridview.
<asp:gridview id="gridview1" runat="server" datakeynames="Id">
<columns>
</columns>
</asp:gridview>

and use it in codebehind
id = Convert.ToDateTime(gridview1.DataKeys[row.RowIndex].Values[0]);
 
Share this answer
 
v2
Try this, Use templateFiled instead of boundfield and keep a hidednfield inside it.
ASP.NET
<asp:templatefield visible="false">
    <asp:hiddenfield id="hdnAttendanceID" runat="server" value='<%=Eval("AttendanceID"); %>'>
    </asp:hiddenfield>
</asp:templatefield>


And later in codebehind Row_Command event
C#
GridViewRow gvr= (GridViewRow) e.CommandSource
HiddenField hdnAttendanceID= (HiddenField)gvr.FindControl("hdnAttendanceID");
string AttendanceID= hdnAttendanceID.Value;
 
Share this answer
 
v4
in VB.net:

C#
grdManualAttendance.Columns(0).Visible= false
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900