Hi,
You may have to make the table a server element by specifying the 'Id' and the runat="server" attributes. After that based on your logic you can make use of the following to add either a colspan or a rowspan to merge the cells / rows.
TableObject.Attributes.Add("colspan", yourValue);
TableObject.Attributes.Add("rowspan", yourValue);
Hope this helps...