|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Hiding columns in GridView controlHi,
I have binded a dataset to a gridview control at run time. I'm fetching 5 columns from the database. But while displaying it on the screen i want to show only 3 columns. I tried with gridview.columns(i).visible property,but it did't work. Thanks in advance Srinivas hi first of all, go to columns property of grid view and the checkbox called
"autogenerate fields should not be ticked. if u see below example then although am fetching 5 columns in dataset, am displaying only 3 namely property address, sales person and date requested. hope this helps. <asp:GridView ID="grdContract" runat="server" AllowSorting="True" AutoGenerateColumns="False" BorderColor="Silver" BorderStyle="Solid" BorderWidth="1px" DataKeyNames="File Number" EmptyDataText="No Contracts Found" Height="189px" OnRowCommand="GetMoreDetails" OnRowCreated="HighlightRow" OnSorting="SortGrdContract" Width="100%" CssClass="customGrid"> <Columns> <asp:TemplateField HeaderText="Property Address" SortExpression="Property Address"> <ItemTemplate> <asp:Label ID="lblPropertyAddress" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.Property Address") %>'> </asp:Label> </ItemTemplate> <ControlStyle Width="180px" /> <ItemStyle HorizontalAlign="Left" /> </asp:TemplateField> <asp:TemplateField HeaderText="Sales Person" SortExpression="Sales Person"> <ItemTemplate> <asp:Label ID="lblSalesPerson" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.Sales Person") %>'> </asp:Label> </ItemTemplate> <ControlStyle Width="120px" /> </asp:TemplateField> <asp:TemplateField HeaderText="Date Requested" SortExpression="Date Requested"> <ItemTemplate> <asp:Label ID="lblDateRequested" runat="server" Text='<%# String.Format("{0:dd/MM/yy}", Convert.ToDateTime(DataBinder.Eval(Container, "DataItem.Date Requested")))%>'> </asp:Label> </ItemTemplate> </asp:TemplateField> </asp:GridView> Show quoteHide quote "srinivas" <srini***@discussions.microsoft.com> wrote in message news:497E8CF6-CB23-4409-9C8F-9FAFE5948F04@microsoft.com... > Hi, > I have binded a dataset to a gridview control at run time. > I'm fetching 5 columns from the database. > But while displaying it on the screen i want to show only 3 columns. > I tried with gridview.columns(i).visible property,but it did't work. > > Thanks in advance > Srinivas
Events fired from dynamically created controls-VB.net
Dynamic button event not firing C# dynamic image? store and retrieve properties values? resizable web control? Correct place to add an event handler in code? Adding layout elements within custom control How to Persist Dynamic Rows within WebControls.Table? Create A 3-Day Window Between 2 Calendars DropDownList -- setting by text? label control Problem with capturing enter key in TextBox within UserControl |
|||||||||||||||||||||||