Gridview and colspan

D

David D.

Can someone easily tell me how to change what the Gridview renders for the
table to get a colspan attribute on selected rows of the table?

In my GridView1_RowDataBound event I am checking the contents of a
particular cell:

If e.Row.Cells(2) = "Something" Then
I want to merge columns 2 and 3 into one (<td colspan=2>)
End If

Thanks, --David
 
P

Phillip Williams

Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
If e.Row.Cells(0).Text.Equals("267-41-2394") Then
'append the content of cell # 2 to cell #1
e.Row.Cells(1).Text += " " & e.Row.Cells(2).Text
'set the columnspan
e.Row.Cells(1).ColumnSpan = "2"
'remove the second cell
e.Row.Cells.Remove(e.Row.Cells(2))

End If
End Sub
 
D

David D.

Great! It was the e.Row.Cells.Remove(e.Row.Cells(2)) that was the secret.
Thanks so much!
 

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

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top