One way could be to change the SelectCommand to something like 'select uPrimaryID AS 'coulmn name of your choice 1', uActive AS 'coulmn name of your choice 2', uGroupId AS 'coulmn name of your choice 3' from yourTableName
Marked as answer by enghsiang on Jun 29, 2007 09:10 AM
you can use an alias for your columns inside your select statement like this: Select
uPrimaryID As ID, uActice As Actice .... and so on. Otherwise you must define your own columns for your gridview:
enghsiang
Member
92 Points
237 Posts
How to change gridview column name ???
Jun 29, 2007 08:02 AM|LINK
i use the gridview to display MySQL database.which i use SQLDataSource to connect to the MySQL.
but i facing the problem that i cant change the column name,it just follow whatever in my database.
this is my code for the gridview:
<asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1" CaptionAlign="Top">
</asp:GridView>
so,how should i change the column name?
help me pls....
addie
Participant
1562 Points
291 Posts
Re: How to change gridview column name ???
Jun 29, 2007 08:25 AM|LINK
One way could be to change the SelectCommand to something like 'select uPrimaryID AS 'coulmn name of your choice 1', uActive AS 'coulmn name of your choice 2', uGroupId AS 'coulmn name of your choice 3' from yourTableName
Zhou
Participant
1428 Points
266 Posts
Re: How to change gridview column name ???
Jun 29, 2007 08:27 AM|LINK
Hello,
you can use an alias for your columns inside your select statement like this: Select uPrimaryID As ID, uActice As Actice .... and so on. Otherwise you must define your own columns for your gridview:
<asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1" CaptionAlign="Top" AutoGenerateColumns="false">
<columns>
<asp:BoundField DataField="uPrimaryID" HeaderText="PrimaryKey" ...... >
</columns>
</asp:GridView>
Regards
Marc André
kaushalparik...
All-Star
26580 Points
3693 Posts
MVP
Re: How to change gridview column name ???
Jun 29, 2007 08:29 AM|LINK
change your select query as...
"SELECT uPrimaryID AS 'Primary ID', uActive AS 'IS Active?', uGroupID AS 'Group ID' FROM TBL_TABLE"
hope this helps./.
[KaushaL] || BloG || Twitter
Don't forget to click "Mark as Answer" on the post that helped you.
hareshmca
Member
351 Points
67 Posts
Re: How to change gridview column name ???
Jun 29, 2007 11:07 AM|LINK
you can use also
GridView1.Columns[4].HeaderText = "HeaderName";
4 is your columns ID assume
Click here to Visite My Site
If you want to be successful, be shameless
If this will not help you out from your problem then please do not Mark As Answer