ASP.NET - how to rename select in gridview. - Asked By chitra ganapathy on 15-Feb-12 03:38 AM

hi, i kept autogenerate select true....the coding and all works fine, my need is how to change the word select to clickhere and want to give header for this column.... plz suggest some idea to change this...
Venkat K replied to chitra ganapathy on 15-Feb-12 03:41 AM
if ((e.Row.RowState == DataControlRowState.Normal | e.Row.RowState == DataControlRowState.Alternate) & e.Row.RowType == DataControlRowType.DataRow) {
	LinkButton SelectButton = (LinkButton)e.Row.Cells(0).Controls(0);
	DataRowView rowView = (DataRowView)e.Row.DataItem;
	string JobTitle = Convert.ToString(rowView["JobTitle"]);
	SelectButton.Text = JobTitle;
}
Somesh Yadav replied to chitra ganapathy on 15-Feb-12 03:44 AM
Hi ,

Try this ,

If you are autogenerating columns, then you will have to change the name of the value that is being databound. This is simple if you have a sql datasource, just alias your columns in your select statement. If you have explicit columns being created, then use the headerText attribute to change it to whatever you want.

<asp:GridView ID="gvMain" runat="server" AutoGenerateColumns="false">
       
<Columns>
           
<asp:BoundField DataField="Books_ID" HeaderText="Book Id" />
           
<asp:BoundField DataField="Text_No" HeaderText="Text No" />
       
</Columns>
   
</asp:GridView>
kalpana aparnathi replied to chitra ganapathy on 15-Feb-12 03:47 AM
hi,

Instead of the AutoGenerateSelectButton, use the CommandField and set its SelectText to specify a different text

http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.commandfield.selecttext%28VS.80%29.aspx

chitra ganapathy replied to Venkat K on 15-Feb-12 03:51 AM
where should i write this code... in page load?
chitra ganapathy replied to kalpana aparnathi on 15-Feb-12 03:59 AM
thanks, its work
kalpana aparnathi replied to chitra ganapathy on 15-Feb-12 04:04 AM
your welcome!!!!!!!!!!!
Venkat K replied to chitra ganapathy on 15-Feb-12 05:17 AM
In the gridview rowDataBound event..