Gridview RowCreated - way to change just first row command text?

K

K B

Hi,

Is there a way to change the EditText value on just the commandfield in
the first row. In the RowCreated event...

If e.Row.RowIndex = 0 Then
...change the edittext on the commandfield

Thanks,
Kit
 
P

PeterKellner

Hi,

Is there a way to change the EditText value on just the commandfield in
the first row. In the RowCreated event...

If e.Row.RowIndex = 0 Then
...change the edittext on the commandfield

Thanks,
Kit

Make sure you change the command row to a template first. Then this
code will do the trick:


protected void GridView1_RowCreated(object sender,
GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{

if (e.Row.RowIndex == 0)
{
LinkButton lb = (LinkButton)
e.Row.FindControl("LinkButton1");
lb.Text = "newtextbutton";
}
}


}
Peter Kellner

(posted the wrong post a minute ago)
Peter Kellner
http://peterkellner.net
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,434
Messages
2,571,689
Members
48,796
Latest member
Greg L.

Latest Threads

Top