12) 10 columns are there in table, but display only 5 columns in grid view. How?

Posted by Fundaravi under ASP.NET on 6/7/2012 | Points: 10 | Views : 1037 | Status : [Member] | Replies : 4
12) 10 columns are there in table, but display only 5 columns in grid view. How? give me with example

Ravindra


Responses

Posted by: Kavi.Sirius on: 6/7/2012 [Member] Starter | Points: 25

Up
0
Down
hi,

write a select query to what are the columns u need to display in gridview

example:

select col1,col2,col3,col4,col5 from tbltame 




Regards
Kavi.n

Fundaravi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Oswaldlily on: 6/7/2012 [Member] Starter | Points: 25

Up
0
Down

gv.datasource="call function where these column names present in storedprocedure"
<asp:gridview.........>
<Columns>
<asp:TemplateField HeaderText="Select">
<ItemTemplate>
<asp:CheckBox ID="chkChange" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="PartNo">
<ItemTemplate>
<asp:Label ID="lblPartNo" runat="server" Text='<%#Eval("Column1") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="GR No">
<ItemTemplate>
<asp:Label ID="lblRNo" runat="server" Text='<%#Eval("Column2") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Line No">
<ItemTemplate>
<asp:Label ID="lblNo" runat="server" Text='<%#Eval("Column3")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="PNo">
<ItemTemplate>
<asp:Label ID="lONo" runat="server" Text='<%#Eval("Column4") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField></column></gridview>


these column1-colum5 shd present in function while binding gridivew

Fundaravi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ajay.Kalol on: 6/7/2012 [Member] Starter | Points: 25

Up
0
Down
Fill DataTable with this query:

SELECT col1,col2,col3,col4,col5 FROM TableName


and bind it with gridview.

Ajay
ajaypatelfromsanthal.blogspot.in

Fundaravi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ashoknalam on: 6/7/2012 [Member] Starter | Points: 25

Up
0
Down
Set autogeneratecolumns="false" and assign the value using <%#Eval("Columnname") %> in itemtemplate of tempaltefield.

Ashok Nalam

Fundaravi, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response